简体   繁体   English

如何根据python中的参数求解具有3个未知数和2个方程的系统

[英]How to solve a system with 3 unknowns and 2 equations depending on a parameter in python

I have these two equation below.我在下面有这两个等式。 I want to solve this system parametrically.我想参数化地解决这个系统。

1.182 * a == 4.0 * b + 4.0

a^2 == 4.0 * b * c + 4.0

It is possible to solve it via MATLAB with the function below.可以通过 MATLAB 使用下面的函数来解决它。 It solves b and c with respect to a.它解决了关于 a 的 b 和 c。

  sol = solve(prob,[b,c]);

result:结果:

b: 0.2956 * a - 1.0 

c: (5.629e+14 * a^2 - 2.252e+15) / (6.656e+14 * a - 2.252e+15)

How can I get the same result in python.如何在 python 中获得相同的结果。 I couldn't find a similar function.我找不到类似的功能。

Upon running运行时

from sympy import Eq, solve, symbols

a, b, c = symbols('a, b, c')
soln = solve((Eq(1.182 * a, 4.0 * b + 4.0),
              Eq(a ** 2, 4.0 * b * c + 4.0)),
             (b, c))
print('\n'.join(sorted(map(str, soln[0]))))

we obtain:我们获得:

0.2955*a - 1.0
500.0*(a - 2.0) * (a + 2.0) / (591.0*a - 2000.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM