sympy's solve() command for equations != 0

我只是一个虾纸丫 提交于 2021-02-05 11:49:40

问题


As i've read in the sympy docs, the solve() command expects an equation to solve as being equal to zero.
As the equations i would like to solve are not in that form and in fact solving them for 0 is my purpose in using a library like sympy, is there a way to get around this?


回答1:


What the docs are saying is that if you do something like

>>> solve(x**2 - 1, x)

Then solve is implicitly assuming that x**2 - 1 is equal to 0. If you wanted to solve x**2 - 1 = 2, then you could either subtract 2 from both sides, to get

>>> solve(x**2 - 1 - 2, x)

or you could use the Eq() class

>>> solve(Eq(x**2 - 1, 2), x)


来源:https://stackoverflow.com/questions/12954552/sympys-solve-command-for-equations-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!