简体   繁体   中英

Is it possible to solve 3 equations with 2 unknowns in Python (Sympy)

Currently using sympy to solve the following set of equations:

from sympy import symbols, Eq, nsolve, exp, log, cosh

eq1 = Eq(Vmax**2/Amax * log(cosh(Amax*4.82/Vmax)),40)
eq2 = Eq(Vmax**2/Amax * log(cosh(Amax*2.8/Vmax)),20)

solution = nsolve([eq1, eq2], [Amax, Vmax], [1, 1])

I get a solution using this technique. However I have a third equation and I would like to solve for the 2 unknowns using all 3 equations. Is it possible to solve for 2 unknowns with 3 equations in Sympy?

from sympy import symbols, Eq, nsolve, exp, log, cosh

eq1 = Eq(Vmax**2/Amax * log(cosh(Amax*4.82/Vmax)),40)
eq2 = Eq(Vmax**2/Amax * log(cosh(Amax*2.8/Vmax)),20)
eq3 = Eq(Vmax**2/Amax * log(cosh(Amax*1.65/Vmax)),10)

solution = nsolve([eq1, eq2, eq3], [Amax, Vmax], [1, 1])

Trying the code above gives a value error: ValueError: Could not find root within given tolerance. (0.181941547657103824541 > 2.16840434497100886801e-19) Try another starting point or tweak arguments. ValueError: Could not find root within given tolerance. (0.181941547657103824541 > 2.16840434497100886801e-19) Try another starting point or tweak arguments.

Can anyone help out or suggest how I can get the values for the 2 unknowns using 3 equations?

Thanks!

The problem is exactly what the error message tells you: there is no solution within the given tolerance. If you want to check consistency for yourself, then solve the equations in pairs, and then compare the solutions with whatever tolerance or other logic you desire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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