Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

Solve inequation composed of FractionFieldElement

asked 2 years ago

IvanaGyro gravatar image

updated 2 years ago

FrédéricC gravatar image

I want to solve an inequation composed of FractionFieldElement.

RF = RealField(300)
P.<x> = RF[]
solve(x ^ 2 / (x + 1) >= 0, x) # TypeError: x is not a valid variable.

I got a TypeError. What can I do?

Preview: (hide)

Comments

This equation cannot be presented as a polynomial:

sage: f = x^2/(x+1) >= 0
sage: expand(f)
x^2/(x + 1) >= 0
sage: f.laurent_polynomial(SR)
...
ValueError: Unable to represent as a polynomial

Without the polynomial ring, the solution is:

RF = RealField(300)
#P.<x> = RF[]
result = solve(x^2/(x+1) >= 0, x)
print(result)

Result:
[[x > -1]]
cmark gravatar imagecmark ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 2 years ago

Emmanuel Charpentier gravatar image

updated 2 years ago

As in your previous question, the lhs() of your inequation (x2x+1) is not a polynomial.

And the solution proposed by Sage :

sage: solve_ineq(x^2/(x+1)>=0, x)
[[x > -1]]

is correct :

  • such an inequation has meaning only for real values ;
  • x being a real, x2 is non-negative ; therefore, x2x+1 has the sign of x+1, which is

    • positive for x>1 (except for x=0, where your lhs() is zero),
    • negative for x<1, and
    • indeterminate for x=1.

These cases exhaust the possibilities for xR.

Now, your inequation may be meaningful if x is a non-real complex with the added constraint x2x+1R. This constraint can be implemented as (x^2/(x+1)).imag()==0. Rewriting x=a+ib, we get :

sage: var("a, b", domain="real")
(a, b)
sage: solve_ineq([(x^2/(x+1)).subs(x==a+I*b).imag()==0, (x^2/(x+1)).subs(x==a+I*b)>=0], [b])
[[b == I*a, 1 != 0, 2*a == 0, 2*a + 1 != 0],
 [b == 0, a + 1 != 0, a^2 + 2*a + 1 != 0, a],
 [a + I*b + 1 > 0,
  a + I*b != 0,
  a^2 + b^2 + 2*a == 0,
  a^2 + b^2 + 2*a + 1 != 0],
 [b == 0, a + 1 > 0, a != 0, a^2 + 2*a + 1 != 0],
 [-a - I*b - 1 > 0,
  -(a + I*b)^2 > 0,
  a^2 + b^2 + 2*a == 0,
  a^2 + b^2 + 2*a + 1 != 0],
 [b == 0, -a - 1 > 0, -a^2 > 0, a^2 + 2*a + 1 != 0]]
  • The first case boils down to x=0 ;
  • the second to x1 (and misses the positivity constraint) ;
  • the third is meaningless/impossible for a,bR (except for a=b=0, which it excludes) ;
  • the fourth is identical to the second ;
  • the fifth leads to the same conclusions than the third ;
  • the sixth is impossible.

Sage's solve_ineq can't find the solutions (if any exists) of this form. This might deserve further exploration, with more advanced techniques (think algebraic geometry...).

EDIT : In this special case, the solution set can be computed "by hand" by rewriting x2x+1 as a+ib, solving x2x+1R (by solving (x2x+1)=0) for b, and substituting each of these solutions to solve (x2x+1)>=0 for a :

sage: ExR=(x^2/(x+1)).subs(x==a+I*b) ; ExR
(a + I*b)^2/(a + I*b + 1)
sage: Sb=ExR.imag().factor().solve(b) ; Sb
[b == -sqrt(-a^2 - 2*a), b == sqrt(-a^2 - 2*a), b == 0]
sage: {u:solve_ineq(ExR.real().factor().subs(u)>=0, a) for u in Sb}
{b == -sqrt(-a^2 - 2*a): [[a >= 0]],
 b == sqrt(-a^2 - 2*a): [[a >= 0]],
 b == 0: [[a > -1]]}

Illustration :

sage: plot([ExR.real().factor().subs(u) for u in Sb], (a, -3, 3), ymin=-5, ymax=5, legend_label=["$%s$"%latex(u) for u in Sb], detect_poles="show")
Launched png viewer for Graphics object consisting of 5 graphics primitives

image description

HTH,

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2 years ago

Seen: 222 times

Last updated: Jan 10 '23