# Decipher Math terms in program-code?

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i want to write a program which can solve math problems. Everything related to functions should be solved by this program e.g.: f(x) = mx + t f(x) = ax² + bx + c It should show one the zeros and the inverse function, and where the functions intersect. It isn't especially with power elements in the term and binomial formulars... What would be the best way to realize this?

##### Share on other sites
This is a very complex problem. However, if you're just considering polynomials with one variable then there is a method to do what you want. You first need a parser to analyse the equation to extract the coefficents. Then, find the eigenvalues of the matrix:
-                     -| -a0/an -a1/an ... -1|| 1      0      ...  0|| 0      1      ...  0|| .      .      ...  .|| 0      0      ...  0|-                     -

to get the roots, where the polynomial is of the form
anxn + ... + a2x2 + a1x + a0 = 0

For further reference visit Math World

Skizz

##### Share on other sites
Your gonna have to give us more details, an option/idea could be to apply the interpreter pattern

##### Share on other sites
Just code in a functional language (or at least prototype in a functional one and then interpret to C) and this kind of problem becomes a walk in the park. Objective Caml (just search it on google) is a pretty good one and comes with just such an interpreter... On the other hand, if you're doing this purely as an excercise in computer science, some appropriate reading would be in the field of numerical methods. You can probably find this stuff in any handy calc text.

##### Share on other sites
Skizz, doesn't finding the eigenvalues of a matrix involve finding roots of a polynomial equation anyway?
How would you use numerical methods to find all the roots, surely a numerical method will find one root at a time. How do you know if you have a double root without factorising?
There are formula for root solving for quadratics, cubics and quartics. The cubic and quartic equations are very long indeed.
There is a method for factorising polynomials of degree 5 and above, but I skived all my lectures on Galois Theory. I got a book out of the library before the exam, but I couldn't understand it at all, and its advanced stuff.

##### Share on other sites
It's been a while since I had to actual do stuff with these (not since University, 12 years back), but yes, looking at now you do end up with more polynomials.
Oops.
As an alternative, try searching google for 'root polynomial' and you'll find what you need.

Skizz

##### Share on other sites
Quote:
 ...eigenvalues ...

Geshundheit.

##### Share on other sites
Thank you guys for all the information you gave me so far. :-)

I want to write such a program only out of curiosity. I want to know if i can achieve it that the program takes a line as input e.g: 5x² + 7x +2 or x³ - 3x² - 5x + 15 and do certain calculations.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 13
• 14