Any libraries to interpret mathematical expressions?

Aug 10, 2010 at 8:03pm
Say that I have a string, char equation[] = "=7*x+2*ln(PI)", and I want to evaluate it using something like double Eqvaluate(char equation[100]). Are there any libraries to do this with (i.e., as Excel does)?

Also, are there any libraries to take derivatives or find integrals (i.e., as Mathematica does)?
Last edited on Aug 10, 2010 at 8:07pm
Aug 10, 2010 at 8:56pm
I'm not aware of any specific libraries, although I'd bet they are out there.

Boost.Spirit can be used to write a parser:
http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/index.html

Here are some applications that use it, a few of which can evaluate basic algebraic expressions:
http://boost-spirit.com/repository/applications/show_contents.php

The Interpreter pattern could also be implemented to perform similar evaluations.
Topic archived. No new replies allowed.