# I have an elliptic curve say y^2=x^3 8. I pick a point P=(1,3) and an arbitrary point Q=(x,y). I want to add the two points on Sage to leave my results in x and y. How do I do that

I want a general formula for addition of two points on an elliptic curve that can be generated by sage.

edit retag close merge delete

Sort by ยป oldest newest most voted

We construct the function field $F$ of the quotient ring of $\Bbb Z[x,y]$ (well, $\Bbb Q$ also works, but will write fractions not as i like them) w.r.t. the ideal generated by $-y^2+x^3+8$. We arrange that in $F$ the two elements have these names. Then consider the elliptic curve with $a_4=0$, $a_6=8$, either directly over $F$, or use a base change from $Q$ to $F$. There are two points, $(1,3)$ and $(x,y)$, and we can add them (generically, something has to be arranged in case of the specialization $x=1$ in practice).

R.<X,Y> = PolynomialRing(QQ)
S.<x,y> = R.quotient(-Y^2 + X^3 + 8)
F = FractionField(S)
E = EllipticCurve(F, [0, 8])
P1, P2 = E.point((1, 3)), E.point((x, y))

print(f"P1 + P2 has the components:\n{(P1 + P2).xy()}")


And we get:

P1 + P2 has the components:
((x^2 + x - 6*y + 16)/(x^2 - 2*x + 1), (-9*x^2 + 3*x*y - 3*y^2 + 33*y - 72)/(3*x^2 - y^2 - 3*x + 9))

more