6

I need a library to be able to parse an equation an give me the result giving the inputs.

For example something like this:

String equation = "5 = 6 / z"; 

EquationSolver solver = new EquationSolver(equation); 

double result = solver.getResult(); 

System.out.println("result: " + result);

And evaluates to: 6/5

Is there any kind of library for java that can do that for me? Basically I need the program to isolate the single unknown variable in an arbitrary equation...

Thanks Thomas

4 Answers4

1

What you're looking for is a computer algebra system.

Wikipedia lists some options. I would check out Java Algebra System

wjin
  • 954
  • 1
  • 8
  • 13
1

You need a Java expression Library for this. I found MVEL to be a good Java Expression Library

You can check this link for other java expression libraries. http://java-source.net/open-source/expression-languages

ravia
  • 11
  • 1
0

Have a look at JPELite.

JEPLite: java expression parser enlited.

Gregory Pakosz
  • 69,011
  • 20
  • 139
  • 164
alphazero
  • 27,094
  • 3
  • 30
  • 26
0

Not sure if you'll find one that's as easy to use as you want, but http://jscl-meditor.sourceforge.net/#mozTocId312653 appears to provide polynomial solving: let me know if that works for you (and how!).

Alternatively JScience may do what you want.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • I've tried to figure out JScience but found it very poorly documented...I can't find samples or anything to guide me :( – evildrsauss Jun 24 '11 at 08:56