I have the quartic curve `v^2 = u^4-2*u^3+5*u^2+8*u+4`

which I convert to an elliptic curve of the form `y^2 + a1*x*y + a3*y = x^3 + a2*x^2 + a4*x + a6`

. The code is given by :

```
var( 'u,v,a,b,c,q,x,y,d' );
f = a*u^4 + b*u^3 + c*u^2 + d*u + q^2
# we want to find an algebraic passage from u, v and the quartic
# v^2 = f
# to a Weierstass equation in two new variables x, y
x = (2*q*(v+q) + d*u)/u^2
y = ((2*q)^3*(v+q) + (2*q)^2*( d*u + c*u^2 ) - d^2*u^2)/((2*q)*u^3)
# inverse transformation:
u = ((2*q)*(x+c)-d^2/q)/y
v = -q + (u*(u*x-d))/(2*q)
# one can easily define rational functions (u,v) -> (x,y) and (x,y) -> (u,v)
# to be used in the concrete situation
a1 = d/q
a2 = c - ((d/(2*q)))^2
a3 = b*(2*q)
a4 = -a*(2*q)^2
a6 = a2*a4
((y^2 + a1*x*y + a3*y) - (x^3 + a2*x^2 + a4*x + a6)).factor()
def passageQuarticToWeierstrass( a, b, c, d, q, field=QQ ):
"""implement the standard formulas
"""
a1, a2, a3, a4 = d/q, c - ((d/(2*q)))^2, b*(2*q), -a*(2*q)^2
a6 = a2 * a4
print ( a1, a2, a3, a4, a6 )
return EllipticCurve(field,(a1, a2, a3, a4, a6))
a, b, c, d, q = 1,-2,5,8,2
E = passageQuarticToWeierstrass( a, b, c, d, q );E
```

The output yield :

```
Elliptic Curve defined by E : y^2 + 4*x*y - 8*y = x^3 + x^2 - 16*x - 16 over Rational Field.
```

Now, I want to transform `E`

into a short Weierstrass equation which should yield : `E' : y^2 = x^3 -3267*x +45630`

with the corresponding change of variable.

This is what I tried, but did not quite worked. (slightly different numerator expression but correct denominators for `u`

and `v`

).

```
reset('x')
reset('y')
var('x,y,Y')
a, b, c, d, q = 1,-2,5,8,2 #coefficients of quartic v^2
a1, a2, a3, a4, a6 = 4, 1, -8, -16, -16 #coefficients of elliptic curve E
E=y^2 + 4*x*y - 8*y -(x^3 + x^2 - 16*x - 16)
F=E.subs({y:y-(a1*x+a3)/2}) #eliminates xy and y term on the LHS of E
eq2=F.canonicalize_radical()
eq3=eq2.subs({x:x-((a2+1/4*(a1)^2)/3)}) #eliminates the x^2 term from the RHS to give E of the form y^2 = x^3 +Ax +B
eq4=eq3.canonicalize_radical()
eq5=eq4.subs({x:(1/3^2)*x})
eq6=eq5*729;eq6
u=((2*q)*(x+c)-(d^2/q))/y #the inverse transformation from from E to quartic
eq7=u.subs({y:y-(a1*x+a3)/2}).subs({x:x-((a2+1/4*(a1)^2)/3)})
eq8=eq7.subs({x : (x/3^2)}).subs({y:y/(3^3)});eq8
v = -q + (u*(u*x-d))/(2*q) #the inverse transformation from from E to quartic
eq9=v.subs({y:y-(a1*x+a3)/2}).subs({x:x-((a2+1/4*(a1)^2)/3)})
eq10=eq9.subs({x : (x/3^2)}).subs({y:y/(3^3)})
eq11=eq10.simplify_full()
eq12=eq11.subs({y^2:(x^3-3267*x+45630)});eq12
```

The output yield :

```
-x^3 + 729*y^2 + 3267*x - 45630 #wrote this in the form:Y^2 = x^3 - 3267*x +45630 where Y=3^3*y
u = -12*(x - 42)/(6*x - y - 198)
v = 2*(x^3 - 162*x^2 + 6291*x + 108*y - 37962)/(x^3 + 36*x^2 - 12*(x - 33)*y - 5643*x + 84834)
```

The problem lies in the expression of `u`

and `v`

. The correct expression is suppose to be

`u = -12*(x - 6)/(6*x - y - 198)`

and

`v = 2*((x^3-18*x^2+3267*x-324*y-71658)/(x^3+36*x^2-12*x*y-5643*x+396*y+84834))`

.

I have checked and have no idea where my coding went wrong that it yields the incorrect numerator but the correct denominator in the expression of `u`

and `v`

. Can someone help me throw in some suggestions.