 Hi. My name is Evie, and today we're going to be talking about algorithms that teach you math. So before we get started, I just want to take a step back and talk about how do humans think about math? How do we solve math? So here's some math. This is an expression that could be simplified. And when I look at this, and probably the same for many of you, I, without even really thinking much about it, know that 8 divided by 4 happens first. Division has precedence over subtraction. Or for something like this, I know I don't even have to do the work of 8 divided by 4. The 2 8 divided by 4 cancel each other out. And so I'm making patterns about math in my mind. And the question we're going to be talking about is, like, how can we get an algorithm or a computer to do these same patterns? And that's what I was thinking about at my internship at a company called Socratic. They make a homework help app, help people answer their homework questions. And when I joined, they were adding math support. And so they wanted a solver that could simplify expressions or solve equations and do that step-by-step. And these were some goals we had for a step-by-step solver. So it should be detailed. So not just here's the answer, but also, you know, all the ways that you get there. Have good explanations, not just what the steps are, but why. And it should feel intuitive. So the things that the algorithm comes up with should be something similar to what a human might come up with, not just some weird answer that gets you there. And nothing was free and open source and focused on teaching. And so we built our own algorithm. And the app using it looked kind of like this at the end of my internship, which was a year and a half ago, so I don't know what it looks like now. But it's called Socratic. Cool. So how do you build a step-by-step math solver? You might be wondering. And we're going to get into that. All right. So you get some ASCII math text input. That is parsed into a tree. That tree is simplified a bunch of times. That's like the step-by-step part until eventually the algorithm decides that there is nothing left to simplify and then it's done. And so what does that mean? So parsing the ASCII math. Here's an example of some ASCII math. It's just a string of characters. I think this is kind of neat. Like in a book, when you read a book, there's a lot of characters on the page, but then you're putting them into words and sentences and paragraphs and ideas. And similarly here, there's just a bunch of characters. But I know that minus three is the argument to the function absolute value. Or the multiplication part has higher precedence, and that's kind of more grouped together than the subtraction part. But the algorithm also needs to be able to think about things like this. We need to make it a bit more formal with trees. So this is what it looks like in a parsed tree. As you can see the minus three, it's an argument to the absolute value function. The multiplication part is kind of like more tightly grouped together than subtraction part because that has like higher precedence. And so all that information is in there. And this is a tree that you can get if you use math.js. They have this great parse function and then does this, we get a tree. And so we use that tree. Computer algebra systems also use trees. And computer algebra systems are just like computers that do, like calculators that do like really fancy math, including simplifying math. And I was thinking, oh, there's this popular computer algebra system called SMPI. And it can simplify math. So what if I just go into the code and like have it show its work? Because like it does some work. Why don't we just use that work as the step by step? And then I looked at their parse tree and it looked like this. So like x minus y plus two thirds was then x plus minus one times y plus two times three to the minus one, which is yeah, the same kind of thing, but also not. I was like, why are you doing this? But it turns out that subtraction and division are kind of annoying for the steps they wanted to take to get to the answer. And they only care about getting to the answer. So like the goals of the computer algebra system was different from our goals, which is the step by step solution. And this tree isn't really helpful for getting to the step by step solution because it immediately gets rid of all of what the user was asking. So we designed our own tree. And part of designing our own tree was we had to think about this arithmetic operations or binary thing, which I had never thought about before. I know that subtraction is binary. It definitely has two arguments. Division is binary. But addition, I was like, oh yeah, that's like adding three numbers together. But no, two plus three plus four is two plus three plus four or two plus three plus four. And so the math.js tree that we got had all the addition was binary. But because addition and also multiplication are communicative and associate of binary operations, they feel like they don't need to be binary, but they could have any number of arguments. So I think of addition more as like the tree on the right and not the tree on the left. And that is what the tree looks like in the math steps algorithm. And it's useful for things like this, where you want to collect and combine like terms. So like, oh look, there are two x's, we can add those things together. Like that's pretty useful in algebra and simplifying expressions. And it turns out it's like way harder to do that when they're all spread out in the tree. But if they're all the same child of the same plus node, then it's a lot easier to find those things to collect and combine together. All right. So we have a parse tree. Next step, we want to simplify it step by step. Oh, baby, gotta get to you girl. Yeah. So here are some examples of simplifying rules. So like something to the zero becoming one or adding two numbers together, or, you know, adding the bottom is like collecting combining like terms, there's like a whole bunch of these. I thought that math was like, pretty intuitive. And then I realized how much things you have to consider at any point. And I was like, Oh, man, math is actually pretty hard. I understand what why everyone thinks this. And the way that these rules are applied is through tree search. So for example, with this rule, you would look the tree, find an exponent node, does it have zero as the exponent? If so, just replace that whole thing with one. And I know that zero to the zero is undefined, but that could be like handled somewhere else with exceptions. And that's pretty much how all of the rules are applied in some order. Some things applied before others. But that's the algorithm. But the algorithm has limitations. And I want to talk about those limitations. For example, different people solve math differently. One example of this is just how many steps do people need. So if someone doesn't really know what's going on, adding more details might be useful or else they won't be able to understand the solution at all. But for other people, you show them 30 steps and they're like, whoa, that's too hard and scary. I don't want to look at that. That's too much and they're overwhelmed. For other people, they might just be kind of like bored if you show them a bunch of steps and they already know how most of that works. So how many steps you show depends on the problem, but it also depends on the person. And this algorithm doesn't take the input of the person and that's a hard problem. There's no best way of solving something and there's no best way of teaching something and here's the way we do it. Which is how the algorithm was designed, but it means it's not perfect. Also, a step-by-step solution isn't a full teaching tool. So it shows how something can be done, but it's not a lesson plan with a full-depth explanation of why everything is happening. So Craddock does a pretty good job of using the Mass Steps algorithm in their app and it's really helpful and lots of people give the Craddock 5-star reviews saying that it helped them figure out math problems and they also get a lot of 5-star reviews of a different kind about how people love using it to cheat because students can cheat and I can talk a whole bunch another time about how the education system makes me sad. But it's important, I think, to realize that step-by-step solutions can be used for this and the implications of making something like that. There's also lots of really cool things you can do with something like Mass Steps. For example, the algorithm, given, let's say, adding fractions together, the way it comes up with those steps is because it can tell that you're adding fractions together. It's like, oh, here are two fractions. Now we're going to do the steps for adding fractions, but if it knows you're adding fractions, it can now give you a video about how to add fractions and that makes it a little bit more of a full-learning experience. Or what if it knows that you're adding fractions together and your friend is adding fractions together and now you can add fractions together together? Because community is a really great way to learn things and you can teach things to your friends and that's a really great learning tool, is to be able to talk to your friends about what you're doing. This one I really like is you make them guess what's happening next so that they actually have to think about the next step, but I kind of feel like a lot of students maybe wouldn't want to do this, sadly, but I think that it would be a really great teaching tool because all the steps are there. They could guess and then you could tell them whether they're right or not or how their thing differs. Or many other things, some things that I've been thinking about that I didn't have time to talk about today, maybe some things that you just thought of. I'd love to talk about that. You're welcome to check it out. There is a demo. I'll post these slides on Twitter and you can see what kinds of stuff it does. It does not solve all math, but it solves some things. You can also check out the source code because it's open source and there's lots of documentation. I'm not really actively maintaining the project right now, but there's lots of stuff in there. I'd love to talk about it if you have any questions or about anything. That is Allgreens of Teaching Math.