简体   繁体   中英

How can i solve this inequality in python? RecursionError: maximum recursion depth exceeded while getting the str of an object

I am trying to get the interval of acceptable values in this inequality:

12/300 < 0.45*sympy.sqrt(Ro/(2*f*x))

where R is calculated in the code.

I want the interval of x . How can I get it?

#Introduzindo as variaveis
P = 50
Vin = 300
Vout = 12
f = 50000
DVout = 0.05
D = 0.45
Ts = 1/f

#Programa
import numpy as np
import sympy
from sympy import *

Ro = Vout**2/P
a = Vout/Vin

x = Symbol('x')
q = solve_univariate_inequality(a <= D*sympy.sqrt(Ro/(2*f*x)), x, S.Reals)

Error:

RecursionError                            Traceback (most recent call last)
<ipython-input-53-6eeaca6392d4> in <module>
     19 # # var('x')
     20 x = Symbol('x')
---> 21 q = solve_univariate_inequality(a <= D*sympy.sqrt(Ro/(2*f*x)), x, S.Reals)
     22 # solvify(D*sympy.sqrt(Ro/(2*f*x)), x, S.Reals)
     23 # # solvify(D*sympy.sqrt(Ro/(2*f*x), x))

12 frames
... last 9 frames repeated, from the frame below ...

/usr/local/lib/python3.7/dist-packages/sympy/solvers/solveset.py in _solveset(f, symbol, domain, _check)
   1060                         result += _solve_radical(equation,
   1061                                                  symbol,
-> 1062                                                  solver)
   1063                     elif equation.has(Abs):
   1064                         result += _solve_abs(f, symbol, domain)

RecursionError: maximum recursion depth exceeded while getting the str of an object

What version of SymPy are you using? I tried with the current version (1.11) and I got:

In [1]: #Introduzindo as variaveis
   ...: P = 50
   ...: Vin = 300
   ...: Vout = 12
   ...: f = 50000
   ...: DVout = 0.05
   ...: D = 0.45
   ...: Ts = 1/f
   ...: 
   ...: #Programa
   ...: import numpy as np
   ...: import sympy
   ...: from sympy import *
   ...: 
   ...: Ro = Vout**2/P
   ...: a = Vout/Vin
   ...: 
   ...: x = Symbol('x')
   ...: q = solve_univariate_inequality(a <= D*sympy.sqrt(Ro/(2*f*x)), x, S.Reals)

In [2]: q
Out[2]: x ≤ 0.003645 ∧ 0 < x

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