如何用 PHP 解方程?

发布于 2024-12-07 17:07:24 字数 494 浏览 0 评论 0原文

我正在寻找 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾听心声的旋律 2024-12-14 17:07:24

从他们的网站查看 Sage

Sage 是一个根据 GPL 授权的免费开源数学软件系统。它将许多现有开源包的强大功能结合到一个基于 Python 的通用界面中。
使命:创建一个可行的免费开源替代品来替代 Magma、Maple、Mathematica 和 Matlab。

Sage 有一个基于 AJAX 的笔记本界面,即可能与您可以从 PHP 使用的 API 一样好。

Check out Sage, from their website:

Sage is a free open-source mathematics software system licensed under the GPL. It combines the power of many existing open-source packages into a common Python-based interface.
Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab.

Sage has an AJAX-based notebook interface, that is probably as good as an API that you can use from PHP.

死开点丶别碍眼 2024-12-14 17:07:24

第一:你的数学解决方案是错误的

  • x+5=8 计算结果为 x=3
  • x+y=-3,y 计算结果为 -x-3

等。

进行数学计算:对 Wolfram|Alpha 进行 API 调用

鉴于这是一项教育事业,我强烈建议您不要创建自己的产品并依赖第三方软件。我个人会选择 Wolfram Mathematica,可能还有他们的 大学预科解决方案 或使用用于 Web 界面的 Web Mathematica

关于 Web Mathematica 的注意事项:它使用 JSP 或 Java Servlet 作为后端技术。有关Web Mathematica 的具体技术细节的更多信息将会有所帮助。

First: your math solutions are wrong.

  • x+5=8 evaluates to x=3
  • x+y=-3, y evaluates to -x-3

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文