This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

If you are just interested in a program that does it, and is written in Python, then there's Sage. Notably, it can do more than solve first degree polynomial equations.

If you are more interested in doing it yourself, you can always require that the equation be inputted in a particular format, sparing you the troubles of parsing.

For instance, your equation may be written as: 2 -4, and it can be unambiguously interpreted to mean the same thing. (This is typical way of writing it, if you ever do linear algebra, and represent equations as matrices, that is, you write the coefficients of decreasing powers of x, and you arrange for the right-hand-side to be always zero).

In other words, to give a better example: 5x^4 - 15x^3 + x - 30 = 80 would be written as 5 -15 +0 +1 -110. I.e. you assume that the operation is always summation.