CoCalc Shared Filestmp / elliptic curve picture.sagewsOpen in CoCalc with one click!
Author: Travis Scholl
Views : 12
Description: Picture of point addition on elliptic curves
import matplotlib.pyplot as plt plt.rc('text', usetex=True) plt.rc('font',**{'family':'serif','serif':['Computer Modern Roman'],'size':14}) E = EllipticCurve([0,4,0,0,1]) P = E.change_ring(RR).lift_x(-0.25)[:2] Q = E.change_ring(RR).lift_x(-3.5,all=true)[1][:2] R2 = (E.change_ring(RR)(P) + E.change_ring(RR)(Q))[:2] R1 = [i*x for i,x in zip(R2,[1,-1])] L1 = [s*(vector(P) - vector(Q)) + vector(Q) for s in [-100,100]] L2 = [s*(vector(R1) - vector(R2)) + vector(R2) for s in [-100,100]] p = E.plot(axes=false,zorder=0) p += line(L1,color="red",zorder=1) p += line(L2,color="red",zorder=1) p += point(P,size=100,zorder=2,color="green") p += text("$\mathcal{P}$",[P[0]-0.5,P[1]],horizontal_alignment="left",color="black",fontsize=20) p += point(Q,size=100,zorder=2,color="green") p += text("$\mathcal{Q}$",[Q[0]-0.5,Q[1]],horizontal_alignment="left",color="black",fontsize=20) #p += point(R1,size=100,zorder=2,color="green") #p += text("$\mathcal{P} * \mathcal{Q}$",[R1[0]-0.8,R1[1]] ,horizontal_alignment="left",color="black",fontsize=20) p += point(R2,size=100,zorder=2,color="green") p += text("$\mathcal{P} + \mathcal{Q}$",[R2[0]+0.25,R2[1]],horizontal_alignment="left",color="black",fontsize=20) p.show(xmin=-4.25,xmax=2,ymin=-4,ymax=4)