Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a script that's solving algebra. I am 16 years old so my script should be able to solve all middle school equations. (Because this is the level I have when it comes to maths. Got the grade: A)

Do anyone have a complete recipe that would apply to all equations?

I've come up with: (I'm from Norway, so the definitions may be a bit odd...)

  1. Multiply in powers outside of brackets.
  2. Try to sum the terms inside the brackets.
  3. Multiply variables, brackets or numbers into a bracket. ($5x(3x+5) = 15x^2+25x$)
  4. Remove unnecessary brackets. (Brackets with + or - in front.)
  5. Sum all the terms.
  6. Sort the terms with $x$s on the left side of the equation sign. The rest on the other side. (Remember to switch negative terms to positive terms and positive terms to negative terms).
  7. Sum all the terms again.
  8. Divide by eventually numbers multiplied with $x$. ($5x = 25$, divide all the terms with $5$ to get $x=5$).

Do you have a recipe that works for every equation you get in middle school, so that I can interpret that into my script?

Thanks! :D

share|cite|improve this question
will your method work for quadratics? – tom Nov 20 '11 at 13:31
#4 requires dynamic programming; – Quixotic Nov 20 '11 at 13:39
Symbolic computation can solve most of the equations given in middle school. However, some things cannot be computed, such as the probability that a random Turing machine will stop. – Angela Richardson Nov 20 '11 at 14:09
It should work for all equations you can find in a middle school math book. I can do the programming here, the question is the mathematics. I want to make a script that do everything like a human would have done it. This is because I want it to show the steps for solving the equation. – Friend of Kim Nov 20 '11 at 14:43
I have no idea what "middle school equations" are, can you write a formal grammar that covers the problems you want to solve? – user16697 Nov 20 '11 at 16:46
up vote 0 down vote accepted

This is somewhat asinine because you often can solve "middle school level" equations more easily by ignoring some of your steps. For instance, it is sometimes more proactive and intelligent to keep parantheses in equations than to completely simplify everything, especially if you are dealing with factors that can be reduced.

share|cite|improve this answer
Yes, you are correct. Thank you! So simplify the parentheses if they cannot be reduced. – Friend of Kim May 30 '12 at 17:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.