Is it possible to define an equation and solve a variable in that equation?
D_PWM, Rsense, A = symbols('D_PWM, Rsense, A')
i_out = D_PWM * (A/Rsense)
print i_out
solve(i_out, Rsense)
Result:
A*D_PWM/Rsense
[]
After the symbols and equations are defined, we can use SymPy's solve() function to compute the value of x and y. The first argument passed to the solve() function is a tuple of the two equations (eq1, eq2) . The second argument passed to the solve() function is a tuple of the variables we want to solve for (x, y) .
To evaluate a numerical expression into a floating point number, use evalf . SymPy can evaluate floating point expressions to arbitrary precision. By default, 15 digits of precision are used, but you can pass any number as the argument to evalf .
i_out has not been declared as a symbol.
>>> from sympy import *
>>> var('D_PWM, Rsense, A i_out')
(D_PWM, Rsense, A, i_out)
>>> eqn=Eq(i_out,D_PWM * (A/Rsense))
>>> solve(eqn,Rsense)
[A*D_PWM/i_out]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With