[EDITATO] come sopra...

In alternativa puoi guardare questo, se ti interessa

http://www.singularsys.com/jep/doc/html/index.html

è un framework aggiuntivo per le espressioni matematiche, è ben fatto