找出方程中的单个未知数
我需要一个库来解析方程并给出输入的结果。
例如这样的:
String equation = "5 = 6 / z";
EquationSolver solver = new EquationSolver(equation);
double result = solver.getResult();
System.out.println("result: " + result);
计算结果为: 6/5
有没有任何类型的 java 库可以为我做到这一点? 基本上我需要程序来隔离任意方程中的单个未知变量......
谢谢 托马斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您正在寻找的是计算机代数系统。
维基百科列出了一些选项。我会查看 Java 代数系统
What you're looking for is a computer algebra system.
Wikipedia lists some options. I would check out Java Algebra System
为此,您需要一个 Java 表达式库。
我发现 MVEL 是一个很好的 Java 表达式库
您可以查看此链接以了解其他 java 表达式库。
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
看看 JPELite。
JEPLite:启用 Java 表达式解析器。
Have a look at JPELite.
JEPLite: java expression parser enlited.
不确定您是否会找到一个像您想要的那样易于使用的工具,但是 http://jscl- meditor.sourceforge.net/#mozTocId312653 似乎提供多项式求解:让我知道这是否适合您(以及如何!)。
或者 JScience 可能会做你想要的。
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.