首先安装sympy库
求解方程 5x + 20 = 100
from sympy import *
x = Symbol('x')
print(solve([5*x + 20 - 100], [x]))
```![在这里插入图片描述](https://img-blog.csdnimg.cn/dffe5e4ec44b4b9babdfbf622c44d7b2.png)
然后是二元一次方程3x + 4y =49, 8x- y = 14
```python
from sympy import *
x = Symbol('x')
y = Symbol('y')
print(solve([3*x + 4*y - 49, 8*x - y - 14], [x, y]))
如果是求解不等式
from sympy import symbols, solve
x = symbols('x')
f1 = 2 * x + 6 - 7 * x + 9
f2 = 2 * (4 * x + 2) - 5 * (x - 1)
print(solve([f1 > 0, f2 >= 0]))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)