Hi Dario, On Sun, Oct 5, 2014 at 6:05 AM, Dario Beraldi <[email protected]> wrote: > Hello, > > Apologies if I'm missing something trivial here... > > I have the function y= sqrt(4*x**2 - 9) for which I want to know the real > domain of definition. I.e. the answer should be: y is defined for x <= -3/2 > and x >= 3/2. > > If I try solve(y >= 0) I get a PolynomialError. I could do solve(y**2 >= 0) > to get the "right" answer but it feels like a hack and I'm wondering whether > there is a better strategy to solve this inequality. Any idea? > > I.m using sympy 0.7.5 and this below is the bit of code to reproduce my > question above. > > Many thanks! > Dario > > isympy > > x= symbols('x') > y= sqrt(4*x**2 - 9) > > ## That's Ok: > solve(y**2 >= 0) ## im(x) = 0 ∧ (re(x) ≥ 3/2 ∨ re(x) ≤ -3/2) > > ## Or even better: > x= symbols('x', real= True) > y= sqrt(4*x**2 - 9) > solve(y**2 >= 0) ## x ≥ 3/2 ∨ x ≤ -3/2 > > ## This doesn't work: > x= symbols('x') > y= sqrt(4*x**2 - 9) > solve(y >= 0) > --------------------------------------------------------------------------- > PolynomialError Traceback (most recent call last) > <ipython-input-14-8865cc4d86ab> in <module>() > ----> 1 solve(y >= 0) > > /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/solvers/solvers.pyc > in solve(f, *symbols, **flags) > 686 elif isinstance(fi, (bool, C.BooleanAtom)) or > fi.is_Relational: > 687 return reduce_inequalities(f, > assume=flags.get('assume'), > --> 688 symbols=symbols) > 689 > 690 # Any embedded piecewise functions need to be brought out to > the > > /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/solvers/inequalities.pyc > in reduce_inequalities(inequalities, assume, symbols) > 514 > 515 for gen, exprs in poly_part.items(): > --> 516 poly_reduced.append(reduce_rational_inequalities([exprs], > gen, assume)) > 517 > 518 for gen, exprs in abs_part.items(): > > /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/solvers/inequalities.pyc > in reduce_rational_inequalities(exprs, gen, assume, relational) > 219 expr.together().as_numer_denom(), gen) > 220 except PolynomialError: > --> 221 raise PolynomialError("only polynomials and " > 222 "rational functions are supported in this > context") > 223 > > PolynomialError: only polynomials and rational functions are supported in > this context
I think you found a bug. Thanks for reporting this. I made this: https://github.com/sympy/sympy/issues/8206 (Feel free to report similar bugs directly to the bug trucker if you want.) Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVAdhT6M5dM%3DaNYopVz8BH4B%2BF4xej4nRTF-YdOR2zuf_Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
