-1

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
1
  • 1
    a <= D... is not how you express an inequality in sympy. Reread the sympy docs about 'relationals'. Commented Sep 13, 2022 at 22:20

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

3 Comments

If the error is not reproducible, then there is not a question. Please read How to Answer and do not use the answer section to say "I tried your code and got a different result". If you changed something, explain what you changed and why. Otherwise, do not answer off-topic questions (the definition here includes questions about problems that cannot be reproduced). I can see that you are not at all new to answering questions on Stack Overflow; I shouldn't need to remind you of this.
@KarlKnechtel, Oscar is one of the top sympy posters here. Let him judge what is a good answer.
The point is that the OP is probably using an older SymPy version and should consider upgrading. Checking now I can reproduce their problem with SymPy 1.7 but as shown here it is fixed in newer versions. It's not "I tried your code and got a different result" but rather "I tried your code with the latest version and got a different result".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.