-
Simplifier and Equation Solver Progress
06/27/2016 at 17:04 • 0 commentsFor 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:
- It can't handle user input containing parenthesis or brackets in them
- It can't handle variables consisting of more than one letter, where each letter may vary in power
- It can't solve equations that are not first degree.
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.
-
Initial Progress
05/01/2016 at 02:35 • 0 commentsI first started off by creating four files: gui.py, translator.py, definitions.py, and solver.py.
- gui.py is the script that will run the graphics user interface for the user, so that the user can type down their math problem and have it submitted to the program.
- translator.py is the script will perform translations in order to make an expression or an input be in a more friendly form for another function or script to use.
- definitions.py is where I'm going to define all the mathematical objects, and operations, such as: variables, constants, and expressions.
- solver.py is where the logic of solving various problems be stored in.
These four files won't be the only files in this program. I plan to add a script that is dedicated in creating the explanations for the step-by-step solutions, storing each step as it is created, and help project that onto the GUI.
As for the actual progress in this project, I have defined classes for variables, constants, and expressions, so that I can define specific operations that can be done to each of these objects in various cases. I did define a few functions in the expression class that will gather like terms, and simplify the expression by step. As of currently, it requires some debugging, since I recently implemented the "constant" class, since initially I was handling constants as strings in my expression, but then I realized that defining operations for them would be all over the place.
This constant class will handle all operations with numbers itself, and it's being used as a parameter for the coefficient and degree for the variable class itself. (It's named "var".) The var class can only handle simple terms, which can only have one letter being raised to a power, but it can't handle having multiple variables, all being raised to different powers. I do plan to fix that, by perhaps creating a new class similar to the variable class that will store all of its letters, and every power associated with each one of them.
I did define a function in translator.py called "translate_input", which will translate the user's input into a form that uses the classes in definitions.py, such as var and constant, and to be able to be used by other classes, such as the expression class as previously mentioned.
I currently have made quite a bit of progress, and I hope I can continue to push forward, and reach a big milestone.