ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 16 Sep 2023 15:37:23 +0200Equivalent of integralQuarticPoints from Magma in Sage?https://ask.sagemath.org/question/73415/equivalent-of-integralquarticpoints-from-magma-in-sage/ In Magma there is a function integralQuarticPoints that can be used to get all the integer solutions to
$$
y^2 = ax^4+bx^3+cx^2+dx+e
$$
when $e$ is a square. There is a function .integral_points() for ElipticCurves, but this is a quartic not an eliptic curve.
Is there a way to do this in Sage?
PS: Would have added link to the docs of the Magma function, but not allowed to due insufficient karma.BikeSat, 16 Sep 2023 15:37:23 +0200https://ask.sagemath.org/question/73415/How to find the generator of the points on the quartic curve?https://ask.sagemath.org/question/52869/how-to-find-the-generator-of-the-points-on-the-quartic-curve/How to find the generator of the points on a quartic curve?
For example, given the curve
y^2 = -2500*x^4 + 451976*x^2 - 2500
how do I find the generator of the points on that curve?GamzeeeWed, 05 Aug 2020 11:36:20 +0200https://ask.sagemath.org/question/52869/change of variables from quartic to weierstrasshttps://ask.sagemath.org/question/40478/change-of-variables-from-quartic-to-weierstrass/ Hi. I have been sitting down for the past 1 week trying to get this code to work with no hope. Can someone help me with the change of variables here please. I have the quartic curve `v^2 = u^4-2*u^3+5*u^2+8*u+4` which I transform 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.
Then I 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 change of variable for `u` and `v` obtained. I tried substituting them back into the curves and they do not satisfy the equations. I suspect the glitch is in `eq6` that is giving me the incorrect change of variable for `u` and `v`. Can someone help me throw in some suggestions. The reason why I am doing all this step by step is because I need to find the change of variable for `u` and `v`.ShaFri, 05 Jan 2018 17:04:28 +0100https://ask.sagemath.org/question/40478/Changes of variable from quartic to Weierstrasshttps://ask.sagemath.org/question/40455/changes-of-variable-from-quartic-to-weierstrass/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.ShaThu, 04 Jan 2018 02:47:48 +0100https://ask.sagemath.org/question/40455/Factor a quadratic in a quartic polynomialhttps://ask.sagemath.org/question/40304/factor-a-quadratic-in-a-quartic-polynomial/Hi, I have done this calculation using a very tedious way and have checked that it is correct. Can I possibly perform this using Sage only.
I have a polynomial :
D=M^2-(A/(2*p^4))*M+(B/(16*p^4))
where
A=18*p^{10} - 54*p^9 + 59*p^8 + 130*p^7 - 209*p^6 - 98*p^5 + 407*p^4 + 362*p^3 + 49*p^2 - 16*p + 8
and
B=9*( p + 1 )^2*(p^4 - 2*p^3 + 2*p^2 + 2*p + 1)*(4*p^8 - 52*p^7 + 373*p^6 + 68*p^5 - 445*p^4 + 72*p^3 + 163*p^2 - 48*p+ 9).
I have checked using multiple software that the factorization of D using the quartic in $p$
`v^2= p^4-2*p^3+5*p^2+8*p+4` gives
`[M-((A+2*F*v)/(4*p^4))]*[M-((A-2*F*v)/(4*p^4))]` where
`F=9*p^8-18*p^7-7*p^6+45*p^5-21*p^4-74*p^3-18*p^2+6*p-2`.
Can someone help me obtain the same result by using Sage only. Thank you.ShaTue, 26 Dec 2017 16:12:52 +0100https://ask.sagemath.org/question/40304/Solving a quartic equationhttps://ask.sagemath.org/question/26993/solving-a-quartic-equation/ I'm attempting to rearrange an equation from an [answer on the Mathematics StackExchange](http://math.stackexchange.com/questions/1298722/find-parametric-line-between-two-2d-line-segments-that-is-an-exact-distance-from).
The answer given is this equation:
$$L^2 = (-ab(t)+p)^2-\left(\frac{(-ab(t)+p).(cd(t)-ab(t))}{(cd(t)-ab(t))^2}(cd(t)-ab(t))\right)^2$$
Where $a$, $b$, $c$, $d$, and $p$ are known 2D points, $L$ is a known length, and $t$ is an unknown scalar. $ab(t)$ indicates interpolation between $a$ and $b$.
I am interested in rearranging this to solve for $t$. Here's what I've tried in Sage:
<pre><code>def sqr(var): return var.dot_product(var)
var('ax bx cx dx px ay by cy dy py t L')
a = vector([ax, ay])
b = vector([bx, by])
c = vector([cx, cy])
d = vector([dx, dy])
p = vector([px, py])
g = a - a*t + b*t
h = c - c*t + d*t
u = p - g
v = h - g
eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
eq.solve(t)
</pre></code>
At the `solve` step I have observed it to sit for quite a while without producing a result. Two questions:
1. Am I inputting the problem correctly?
2. Is there any way to know if this is likely to terminate in a reasonable time? I have no idea what the solver looks like under the hood, and wouldn't want to wait for some `O(n!)` calculation to terminate :)
nicholasbishopMon, 01 Jun 2015 04:51:26 +0200https://ask.sagemath.org/question/26993/