# simplifying expression

I have been trying to simplify this expression but with no luck. I checked using PARI, it indeed gives 0, means the change of variable p and v do satisfy the curves given. Can someone drop me a hint on how to work this out.

> p,x,v,y= var('p x v y')
> p=(-72*x-264+36*y)/(9*x^2+30*x-119)
> v=(-162*x^4+540*x^3-648*x^2*y+13176*x^2-4752*x*y+62340*x-16488*y+153994)/(81*x^4+540*x^3-1242*x^2-7140*x+14161)
> eq1=expand(v^2-(p^4-2*p^3+5*p^2+8*p+4))
> eq=eq1.subs({y:sqrt(-x^3+(121/3)*x+(1690/27))}).subs({sqrt(-x^3+(121/3)*x+(1690/27)):y})
> eq2=eq.simplify_full();eq2


The output gave :

3456*(27*(-x^3 + 121/3*x + 1690/27)^(3/2)*(9*x^2 + 174*x + 409) + (243*x^5 + 4698*x^4 + 1242*x^3 - 204696*x^2 - 739461*x - 691210)*y)/(6561*x^8 + 87480*x^7 + 90396*x^6 - 2498040*x^5 - 3874554*x^4
+ 33029640*x^3 + 15803676*x^2 - 202219080*x + 200533921)


It is suppose to be zero (I have checked). Problem lies at the expression 3456*(27*(-x^3 + 121/3*x + 1690/27)^(3/2). This term should be simplified into somewhat y^2*y=(-x^3 + 121/3*x + 1690/27)*y. It will then simplify and give 0. But how to work that out.

edit retag close merge delete

Sort by » oldest newest most voted

The issue lies in the power 3/2, which requires canonicalize_radical to be simplified. This method is not included in simplify_full because it has some arbitrariness in the choice of square roots.

First of all, you should not perform the double substitution in eq1, but keep only the first one:

sage: eq=eq1.subs({y:sqrt(-x^3+(121/3)*x+(1690/27))})


Then you are done:

sage: eq2=eq.canonicalize_radical(); eq2
0


For more details on canonicalize_radical, type eq.canonicalize_radical?.

more

Note that after the second when eq2 is built, there is no reason to still assume a dependency of the variables x, y. The value of eq2 is factorized is simply not zero:

p,x,v,y = var('p x v y')
p = (-72*x-264+36*y)/(9*x^2+30*x-119)
v = (-162*x^4+540*x^3-648*x^2*y+13176*x^2-4752*x*y+62340*x-16488*y+153994) \
/ (81*x^4+540*x^3-1242*x^2-7140*x+14161)
eq1 = expand(v^2-(p^4-2*p^3+5*p^2+8*p+4))
eq  = eq1 \
. subs( { y : sqrt(-x^3+(121/3)*x+(1690/27))     } ) \
. subs( {     sqrt(-x^3+(121/3)*x+(1690/27)) : y } )
eq2 = eq.simplify_full()
print eq2.factor()


gives:

3456*(27*x^3*y - 1089*x*y + 27*(-x^3 + 121/3*x + 1690/27)^(3/2) - 1690*y)*(9*x^2 + 174*x + 409)/((3*x + 17)^4*(3*x - 7)^4)


This is not zero. Substituting something like . subs( { sqrt(-x^3+(121/3)*x+(1690/27)) : y } ) is a very fragile and unpredictable operation. Instead, one can work algebraically, and simply get the answer to the question that can be mathematically extracted from the posted wish:

Assume that $x,y$ satisfy the algebraic dependency: $$y^2 =-x^3+\frac {121}3x+ \frac{1690}{27}\ .$$ Show than that the variables $p,v$ given in the posted code satisfy $$v^2=p^4-2p^3+5p^2+8p+4\ .$$

For this, we can work as follows:

R.<x,y> = PolynomialRing( QQ )
J = R.ideal( [ -x^3 + 121/3*x + 1690/27 - y^2 ] )
Q = R.quotient(J)

p = (-72*x - 264 + 36*y) / (9*x^2 + 30*x - 119)
v = (-162*x^4 + 540*x^3 - 648*x^2*y + 13176*x^2 - 4752*x*y + 62340*x - 16488*y + 153994) \
/ (81*x^4 + 540*x^3 - 1242*x^2 - 7140*x + 14161)

eq = (v^2 - (p^4 - 2*p^3 + 5*p^2 + 8*p + 4) ).numerator()

print "The parent of eq is:\n%s" % eq.parent()
print "Is R the parent? %s" % bool( R ==eq.parent() )
print "The image of eq in the quotient ring Q is: %s" % Q(eq)


This gives:

The parent of eq is:
Multivariate Polynomial Ring in x, y over Rational Field
Is R the parent? True
The image of eq in the quotient ring Q is: 0


The above is the solution inside algebraic geometry, arguably the best, the purist world. (Sage also tolerates tacitly expressions in the quotient field of $R$, as $v,p$ are constructed.)

Alternative solution, using only one variable and using "the" radical:

var( 'x' )

y = sqrt( -x^3 + 121/3*x + 1690/27 )

p = (-72*x - 264 + 36*y) / (9*x^2 + 30*x - 119)
v = (-162*x^4 + 540*x^3 - 648*x^2*y + 13176*x^2 - 4752*x*y + 62340*x - 16488*y + 153994) \
/ (81*x^4 + 540*x^3 - 1242*x^2 - 7140*x + 14161)

(v^2 - (p^4 - 2*p^3 + 5*p^2 + 8*p + 4) ).factor()


This gives me:

0
sage: version()
'SageMath version 8.1, Release Date: 2017-12-07'


(Some older sage version may fail to factor expressions that evaluate to zero.)

more