线性数学方程的方程求解器
我需要在我的应用程序中求解一些数学方程。 这是此类方程的典型示例:
a + b * c - d / e = a
附加规则:
- b % 10 = 0
- b >= 0
- b <= 100
- 每个数字必须是整数
- ...
我想获得 a、b、c 的可能解集、d 和 e。
是否有任何库,无论是开源的还是商业的,我可以用它们来求解这样的方程? 如果是,他们会提供什么样的结果?
I need to solve a few mathematical equations in my application. Here's a typical example of such an equation:
a + b * c - d / e = a
Additional rules:
- b % 10 = 0
- b >= 0
- b <= 100
- Each number must be integer
- ...
I would like to get the possible solution sets for a, b, c, d and e.
Are there any libraries out there, either open source or commercial, which I can use to solve such an equation? If yes, what kind of result do they provide?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
求解线性系统通常可以使用线性规划来求解。 我建议查看 Boost uBLAS 对于初学者来说 - 它有一个简单的三角形解算器。 然后,您可以查看针对更多特定领域方法的库,也许是 QSopt。
Solving linear systems can generally be solved using linear programming. I'd recommend taking a look at Boost uBLAS for starters - it has a simple triangular solver. Then you might checkout libraries targeting more domain specific approaches, perhaps QSopt.
您正在冒险进入数值分析的世界,这里有龙。 规格上看似微小的差异可能会对正确的方法产生巨大的影响。
如果没有对问题领域进行相当精确的描述,我会犹豫是否提出具体建议。 听起来表面上就像您正在解决约束线性问题,这些问题非常简单,有很多方法可以做到这一点,但“...”可能是一个问题。
对于一般求解器等来说,一个很好的资源是 GAMS。 对于您所要求的功能来说,许多软件可能有点重。
You're venturing into the world of numerical analysis, and here be dragons. Seemingly small differences in specification can make a huge difference in what is the right approach.
I hesitate to make specific suggestions without a fairly precise description of the problem domain. It sounds superficiall like you are solving constrained linear problems that are simple enough that there are a lot of ways to do it but "..." could be a problem.
A good resource for general solvers etc. would be GAMS. Much of the software there may be a bit heavy weight for what you are asking.
你想要一个计算机代数系统。
请参阅https://stackoverflow.com/questions/160911/symbolic-math-lib,其答案大多与 c++ 和 c 相关。
You want a computer algebra system.
See https://stackoverflow.com/questions/160911/symbolic-math-lib, the answers to which are mostly as relevant to c++ as to c.
我知道这不是你真正的问题,但你可以将给定的方程简化为:
d = b * c * e with e != 0
I know it is not your real question, but you can simplify the given equation to:
d = b * c * e with e != 0
很确定数字食谱会有一些东西
Pretty sure Numerical Recipes will have something
您正在寻找计算机代数系统,这不是一件小事。
不过,其中很多都是可用的,请尝试维基百科上的此列表:
http://en.wikipedia.org/ wiki/Comparison_of_computer_algebra_systems
- Adam
You're looking for a computer algebra system, and that's not a trivial thing.
Lot's of them are available, though, try this list at Wikipedia:
http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems
-Adam
这看起来像线性规划。 此列表有帮助吗?
This looks like linear programming. Does this list help?
除了其他帖子之外。 您的约束集让人想起整数编程问题,因此您可能也想检查一下此类问题。 也许您的问题可以(重新)表述为一个。
然而,您必须知道,整数编程问题往往是较难的计算问题之一,因此您最终可能会使用许多时钟周期来破解它。
In addition to the other posts. Your constraint sets make this reminiscent of an integer programming problem, so you might want to check that kind of thing out as well. Perhaps your problem can be (re-)stated as one.
You must know, however that the integer programming problems tends to be one of the harder computational problems so you might end up using many clock cycles to crack it.
仅查看“附加规则”部分,它确实看起来像线性编程,在这种情况下,LINDO 或实现单纯形算法的类似程序应该没问题。
但是,如果第一个方程确实是典型,则表明您的方程不是线性代数问题 - 线性方程中不应该出现两个相互乘法或除法的变量!
所以我想说你肯定需要计算机代数系统或使用遗传算法解决问题。
由于您的限制类似于线性编程中的限制,尽管您还没有完全做到这一点,如果您只想解决您的特定问题,我会说选择 维基百科关于遗传算法的文章 并开发一个应用程序来为您提供结果。 如果您想要一种更通用的方法,那么您必须在计算机上模拟代数运算,别无选择。
Looking only at the "additional rules" part it does look like linear programming, in which case LINDO or a similar program implementing the simplex algorithm should be fine.
However, if the first equation is really typical it shows yours is NOT a linear algebra problem - no 2 variables multiplying or dividing each other should appear on a linear equation!
So I'd say you definitely need either a computer algebra system or solve the problem using a genetic algorithm.
Since you have restrictions similar to those found in linear programming though you're not quite there, if you just want a solution to your specific problem I'd say pick up any of the libraries mentioned at the end of Wikipedia's article on genetic algorithms and develop an app to give you the result. If you want a more generalist approach, then you've got to simulate algebraic manipulations on your computer, no other way around.
TI-89 计算器有一个“求解器”应用程序。
它是为了解决像您的示例中的问题而构建的。
我知道它不是图书馆。 但市面上有多种 TI-89 仿真器。
The TI-89 Calculator has a 'solver' application.
It was built to solve problems like the one in your example.
I know its not a library. But there are several TI-89 emulators out there.