Search code examples
javamathbeanshell

How would someone implement mathematical formulae in Java?


How would someone implement mathematical formulae in Java?

What I mean, the user inputs a string with multiple variables. Like a simple quadratic formula: x^2 + 5x + 10. Or in Java: (Math.pow(x,2)) + (x * 5) + 10. The user would then enter that and then the program would solve for x. I will be using the BeanShell Interpreter class to interpret the string as an equation. But how would I solve for x?


Solution

  • This is a hard problem, unless you restrict yourself to simple equation types.

    Here are some links for you to chase:

    Trawling through the second link, I spotted 3 open-source Java systems.