%hide
html('<h3>Point Addition for Elliptic Curves over the Rational Numbers</h3>')
@interact
def _(a = (-4,(-10..3)), b = (4,(-10..10)), xP = input_box(default=2,width=12), xQ = input_box(default=1,width=12),
negyP = checkbox(label='negative yP',default=False),negyQ = checkbox(label='negative yQ',default=False)):
if 4*a^3 + 27*b^2 == 0:
html('The choice of $a$ = %d and $b$ = %d does not define an elliptic curve because this makes $27a^3 + 4b^2 = 0.$'%(a,b))
return
E = EllipticCurve(QQ,[a,b])
if not E.is_x_coord(xP):
html('<font size=5>The choice of xP = $%s$ does not define a rational point on $E: %s.$</font>'%(latex(xP),latex(E)))
plot(EllipticCurve([a,b]),xmax=3).show()
return
if not E.is_x_coord(xQ):
html('<font size=5>The choice of xQ = $%s$ does not define a rational point on $E: %s.$</font>'%(latex(xQ),latex(E)))
plot(EllipticCurve([a,b]),xmax=3).show()
return
P = E.lift_x(xP)
if negyP: P = -P
yP = P[1]
pP = plot(P,pointsize=50,rgbcolor="red")
Q = E.lift_x(xQ)
if negyQ: Q = -Q
yQ = Q[1]
pQ = plot(Q,pointsize=50,rgbcolor=[1,0.4,0])
R = P+Q
xR = R[0]
yR = R[1]
m = max(2.5,xP,xQ,R[0])
pE = plot(E,xmax=m+0.5)
pl = line([(xP,yP),(xQ,yQ),(xR,-yR)], rgbcolor = (1,0.8,0),thickness=1)
pll = line([(xR,-yR),(xR,yR)],rgbcolor=(1,0.8,0),thickness=1,linestyle='--')
s = '<font color="blue">$E(\mathbb{Q}) = \{ (x,y) \in \mathbb{Q} \\times \mathbb{Q}\ |\ %s \} \cup \{ \mathcal{O} \}$</font>'%(latex(E))
s += '\n<font color="red">$P = (%s,%s)$</font> <font color="#FF6600">$Q = (%s,%s)$</font> '%(P[0],P[1],Q[0],Q[1])
if R == E([0,1,0]):
s += '$P + Q = \mathcal{O}$'
graph = pE+pP+pQ+line([P,Q],rgbcolor=(1,0.8,0),thickness=1,linestyle='--')
else:
s += '$R = P + Q$'
pR = plot(R,pointsize=50,rgbcolor=(0,0.5,0))
pRm = plot(-R,pointsize=50,rgbcolor="green")
if P == Q:
lam = (3*xP^2+a)/(2*yP)
s += '\n$\lambda = \\frac{3 x_P^2+a}{2 y_P} = \\frac{3 (%s)^2+(%s)}{2 (%s)} = %s$'%(latex(xP),latex(a),latex(yP),latex(lam))
else:
lam = (yQ-yP)/(xQ-xP)
s += '\n$\lambda = \\frac{y_Q - y_P}{x_Q - x_P} = \\frac{%s - (%s)}{%s - (%s)} = %s$'\
%(latex(yQ),latex(yP),latex(xQ),latex(xP),latex(lam))
xR = lam^2 - xP - xQ
s += '\n$x_R = \lambda^2 - x_P - x_Q = ( %s ) ^2 - (%s) - (%s) = %s$'%(latex(lam),latex(xP),latex(xQ),latex(xR))
yR = lam*(xP-xR) - yP
s += '\n$y_R = \lambda (x_P - x_R) - y_P = %s (%s - (%s)) - (%s) = %s$'%(latex(lam),latex(xP),latex(xR),latex(yP),latex(yR))
s += '\n$\Rightarrow$ <font color="#008000">$R = (%s,%s)$</font>'%(latex(xR),latex(yR))
graph = pl+pll+pE+pP+pQ+pR+pRm
R = E([xR,yR])
if R != P+Q:
html('Fehler, falsches Ergebnis!!!')
html('<font size=5>'+s+'</font>')
show(graph,axes_labels=['x','y'])
html('Figure 3.7 Try adding some points. You may choose the curve parameters a and b, and the x-coordinates xP and xQ of the <br>points P and Q that you wish to add (type them in the format 2.5 or 5/2). The program then determines the appropriate <br>y-coordinate (such that (x,y) solves the curve equation). By default, it always takes the positive value for y. You can tell the <br>program to use the negative value by checking the appropriate negative yP or negative yQ box. Although we are working <br>with curves over the rational numbers, not every rational number is a valid x-coordinate (this is only the case if the <br>corresponding y-coordinate is also rational). The program will inform you in such a case and you will have to choose a <br>different value.')
|
|
Point Addition for Elliptic Curves over the Rational Numbers
Figure 3.7 Try adding some points. You may choose the curve parameters a and b, and the x-coordinates xP and xQ of the points P and Q that you wish to add (type them in the format 2.5 or 5/2). The program then determines the appropriate y-coordinate (such that (x,y) solves the curve equation). By default, it always takes the positive value for y. You can tell the program to use the negative value by checking the appropriate negative yP or negative yQ box. Although we are working with curves over the rational numbers, not every rational number is a valid x-coordinate (this is only the case if the corresponding y-coordinate is also rational). The program will inform you in such a case and you will have to choose a different value.
Click to the left again to hide and once more to show the dynamic interactive window
|