Close

Simplifier and Equation Solver Progress

A project log for MathSolver

A program written entirely in Python to solve mathematical problems with step-by-step solutions.

jasmeet-brarJasmeet Brar 06/27/2016 at 17:040 Comments

For the last few weeks, I was able to make massive progress in debugging the methods of the variable, constant, and expression classes; and I was able to move forward and make a simplify-by-step method, which would give us the new expression as a result of the simplifying the current expression that we have. Then I moved on and defined a base class for equations in general, and I had defined the one variable equation class, which would inherit from the equation class. The good news about this is that I am able to solve any one variable equations, with some limitations though.

The limitations that I have in my program are:

The biggest limitation is the first one: it can't handle parenthesis and brackets. A lot of problems in mathematics involve these symbols in order to define which operation goes first, or clarify what the inclosed part is. For example, the program must interpret the terms in parenthesis of "x^(2y-5)" as part of the exponent of x.

I could fix this, by tweaking the user input translator so it can handle these operators, but it will be a lot of work, since the meaning of the operator can vary on where it is placed in the expression. It could indicate multiplication, such as 3(5); it could indicate that the containing operations go first, such as 3-(2-5), or it could clarify what the inclosed part is, as mentioned before.

There is a solution to this and that is to implement a data structure known as binary expression tree, as a way to represent expressions. The advantage to this is that it knows which operators goes first, so it doesn't show the parenthesis or brackets in the tree itself. Another advantage is that it allows me to define more functions in the future, without having to go through the mess of handling the brackets. Examples of such functions are: trigonometric functions, and logarithm functions.

This is a massive undertaking, since I would have to take the user input in infix notation, and output a binary tree, or a list of them if it's an equation. I could try to translate the expression in infix notation into Reverse Polish Notation, which may be easier for me to work with. After that, I have to program the simplifier and the one variable equation solver again, so this will set me back. But I think it will be a worthy investment.

The other limitations will be taken care of, after I handle the first one.

I hope I'll be able to make a breakthrough.

Discussions