I’m looking for a generalized equation solver in PHP. This could either be in the form of in-built functionality, a library, or even integration with another language if it comes to it. I am even comfortable with a joint solution that involves some combination of the above. I need this for an educational website on which I am working.
Let me give a series of equations that I would ideally expect such a solver to deal with:
x+5=8 => x=3
x^2=5 => x=+/-sqrt(5) [exact solution in terms of sqrt, ln, or whatever] AND
x=+/-2.236 [approximate solution to certain number of digits]
x+y=-3 [solve in terms of y] => y=-x-3
x^2=-5 => x=+/5i
x+y=3 and x-y=3 => x=3, y=0
I hope this is not a bridge too far. If so, I’ll build the functionality as each problem comes in-house, but if anyone knows of the proper library for such a set of problems, I would greatly appreciate it.
Check out Sage, from their website:
Sage has an AJAX-based notebook interface, that is probably as good as an API that you can use from PHP.