mathematica 线性方程组的非负整数解
与我之前的问题相关,只是想知道如何求解具有非负积分解的线性方程组,例如:
c11*x+c12*y+c13*z=d1
c21*x+c22*y+c23*z=d2
非常感谢!
编辑
我的意思是高效。例如,我可以使用 FrobeniusSolve 来获取两个解列表并尝试找到交集。但有时,单个解决方案列表可能非常大。或者尝试验证一个 FrobeniusSolve
返回的每个单独的解,看看它们是否满足所有剩余的方程,但这也有同样的缺点。
Related to my previous question, just wonder how to solve a system of linear equations with non-negative integral solutions, for example:
c11*x+c12*y+c13*z=d1
c21*x+c22*y+c23*z=d2
Thanks a lot!
Edit
I meant efficiently. For example, I could have used FrobeniusSolve
to get two solution lists and try to find the intersection. But sometimes, the individual solution list is probably hugely large. Or try to verify each individual solution returned by one FrobeniusSolve
to see whether they satisfy all the remaining equations, but that suffers from the same drawback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
Reduce
能够解决这类问题。要回答上面评论中的具体情况:
编辑:
您可以通过分别求解两个方程并取其解的交集来检查这是否与您获得的解相同:
并且您可以通过以下方式提取解:
将解决方案转化为替换规则列表
并应用于变量:
Reduce
is able to solve these types of problems.To answer the specific case in your comment above:
Edit:
You can check that this is the same solution you get by solving the two equations separately and taking the intersection of their solutions:
And you can extract the solutions by, e.g.,
turning the solutions into a list of replacement rules
and applying to the variables: