I’m working on java program that can compute the differentiation of any given mathematical expression.
When User types the expression say Sin(Cos(x^2)) I need to check whether it is mathematically valid or not.
Of course we can do it by manual code writing but that would be tedious work.
Can I do it using regex package of java??
How??
thanx..
No, regexes aren’t sufficient… (in fact, this can be mathematically proved).
To parse mathematical expressions, you can either write your own parser (which isn’t actually that hard) or use an existing one, such as Jep.
Here are some previous SO questions on parsing mathematical expressions:
Best algorithm for evaluating a mathematical expression?
Reading and running a mathematical expression in Python
Evaluating mathematical expressions