如何用 PHP 解方程?
我正在寻找 PHP 中的通用方程求解器。这可以是内置功能、库的形式,甚至可以是与另一种语言集成的形式(如果需要的话)。我什至对涉及上述内容的联合解决方案感到满意。我正在工作的一个教育网站需要这个。
让我给出一系列我希望这样的求解器能够处理的方程:
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'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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从他们的网站查看 Sage:
Sage 有一个基于 AJAX 的笔记本界面,即可能与您可以从 PHP 使用的 API 一样好。
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.
第一:你的数学解决方案是错误的。
等。
进行数学计算:对 Wolfram|Alpha 进行 API 调用。
鉴于这是一项教育事业,我强烈建议您不要创建自己的产品并依赖第三方软件。我个人会选择 Wolfram Mathematica,可能还有他们的 大学预科解决方案 或使用用于 Web 界面的 Web Mathematica。
关于 Web Mathematica 的注意事项:它使用 JSP 或 Java Servlet 作为后端技术。有关Web Mathematica 的具体技术细节的更多信息将会有所帮助。
First: your math solutions are wrong.
etc.
To do the math: make an API call to Wolfram|Alpha.
Seeing as this is an educational venture, I would highly suggest that you do not create your own product and rely on third-party software. I would personally go with Wolfram Mathematica, and probably their pre-college solutions or go with Web Mathematica for web interfaces.
Note about Web Mathematica: it uses JSP or Java Servlets for it's back-end technology. More about specific technical details for Web Mathematica will be helpful.