>  # Introduction to elliptic curves
# A. Betten 12/4/05 # for M360 Colorado State University 
>  # start with a cubic polynomial with three real roots: 
>  f(x) := x * (x+1) * (x1); 
>  plot(f(x),x=2..2); 
>  # now take the square root: 
>  plot(sqrt(f(x)),x=2..2); 
>  # actually, we have two branches, the positive
# and the negative one. We get two components 
>  plot([sqrt(f(x)),sqrt(f(x))],x=2..2); 
>  # now a cubic with complex roots: 
>  g(x) := x^3 + 73; 
> 
>  plot(g(x),x=5..5); 
>  # this time, we have only one component. In both cases,
# we say that we have a curve in the real x/y plane. # the equation of the curve is # y^2=g(x) 
>  plot([sqrt(g(x)),sqrt(g(x))],x=5..5); 
>  # save the plot for future use. 
>  C := plot([sqrt(g(x)),sqrt(g(x))],x=5..5): 
>  with(plottools): 
>  with(plots): 
Warning, the previous binding of the name arrow has been removed and it now has an assigned value
>  display(C); 
>  # there is a special command for plotting curves,
# it is implicitplot 
>  implicitplot(y^2x^373,x=5..5,y=12..12); 
>  C := implicitplot(y^2x^373,x=5..5,y=12..12): 
>  # x=3 gives y=9 (and y=9), i.e. we have found
# an integral point on the curve 
>  P1 := pointplot({[2,9]}); 
>  display(C,P1); 
>  # BTW, such a curve is called elliptic curve. 
>  # x=3 gives y=10 (and 10), ie we have found another
# integral point on the curve 
>  P2 := pointplot({[3,10]}); 
>  display(C,P1,P2); 
>  # Let's determine the line through the two points.
# Its equation is y = x+7 # check: plugging in 2 gives 9, plugging in 3 gives 10. 
>  L := plot(x+7,x=5..5): 
>  display(C,P1,P2,L); 
>  # the line L intersects the curve in another point. 
>  solve(sqrt(g(x))(x+7),x); 
>  # OK, the third point is at x=4 
>  simplify(eval(sqrt(g(x)),x=4)); 
>  # that was a bit complicated, but the thrid
# integral point is # P3 = (4,3) 
>  P3 := pointplot({[4,3]}); 
>  display(C,L,P1,P2,P3); 
>  # the main point was that knowing two (integral)
# points on the curve # enabled us to produce another (integral) point. 
>  # now comes a nice trick from algebraic geometry:
# we substitute x=X/Z and y = Y/Z into the # equation of the curve to get # Y^2/Z^2 = X^3/Z^3 + 73 # and hence # Y^2Z = X^3 + 73Z^3 # this is an equation of a curve in 3 variables. # The equation is homogeneous of degree 3. # This means that whenever (X,Y,Z) is a solution, # then also any nonzero scalar multiple # (aX,aY,aZ) is a solution. # In particular, we find that the points (x,y,1) # are solutions, provided (x,y) was a solution # to the original equation. # In addition, there is the solution (0,1,0). # We may think of the scalar multiples of (X,Y,Z) # as being an entity, called a projective point. # To express the fact that we consider scalar multiples, # we write (X:Y:Z). # The new points (X:Y:1) behave much like the old points, # more precisely, they are in 11 correspondence. # In addition, the curve has the new point (0:1:0), # which we may imagine as sitting on top of the Yaxis. # (and also at the very bottom of the Yaxis). # We have just introduced the projective plane # over the reals. It looks much like the ordinary # (affine) plane except that it has points # (X:Y:0) which we may imagine as sitting far out. # We say that these are the points at infinity. # So, projectively, the elliptic curve has one more # point than it has in the affine plane. 
>  # Let's look at what happens to lines.
# The vertical lines of the form x=c, c a constant, # become X/Z=c or X=cZ. # Thus, the point at infinity (i.e. Z=0) # (0:1:0) is on all these vertical lines. # Lines of the form y = mx + c become # Y/Z = mX/Z + c or Y = mX + cZ. # The point at infinity (1:m:0) is on all those lines # for fixed m, i.e. for fixed slope. # That is, the parallel lines of the form # y = mx + b for fixed m and various b # all intersect in the point (1:m:0). # The vertical lines all intersect in (0:1:0). # Sadly enough, there is no Maple command to plot # curves in the projective plane. # As a curiosity, the line Z=0 is a line # which contains all the points at infinity. # This line contains no affine point, and hence # cannot be seen in the affine x/yplane. 
>  # From now on, let us identify (x,y) with (x:y:1).
# Also, it is usual to denote (0:1:0) as infinity. # The main idea is to introduce a group structure # on the points of an elliptic curve as follows: # infinity is the identity element in the group. # For points P,Q,R we say that # P + Q + R = infinity (=0) # if and only if P,Q,R are collinear 
>  display(C,L,P1,P2,P3); 
>  # this is just saying that P1+P2+P3 = 0. 
>  # It is a nice fact that in the projective plane,
# a line intersects the elliptic curve in exactly # three points, provided one counts points with # the appropriate multiplicities, i.e. a # tangent point counts twice. # In other words, three points add to infinity # (ie zero in the group) if they are collinear # (collinear = being on a line). # Since the vertical lines intersect at infinity, # we automatically have that if P=(x,y) then P=(x,y) # since (x,y),(x,y),infinity are collinear. 
>  P3 := pointplot({[4,3]}); 
>  P3minus := pointplot({[4,3]}); 
>  L3 := implicitplot(x+4,x=5..5,y=12..12): 
>  display(C,P3,P3minus,L3); 
>  # Thus, to add points P and Q, one rewrites
# the fundamental equation P+Q+R=infinity as # P+Q=R. Thus, to compute P+Q one has to take the # line through P and Q, intersect it with the curve # to get R = (x,y). Then P+Q = R = (x,y). # Thus, P1+P2=P3, i.e. 
>  display(C,P1,P2,P3minus,L,L3); 
>  # The crucial point is that the resulting
# addition is assiciative, i.e. # P+(Q+R) = (P+Q)+R. # Showing this is nontrivial. 
>  # It is possible to write down general formulas
# for the addition of points on the curve. # To add a point P to itself, one draws the tangent # line to the curve at that point and intersects # it with the curve. Negation of the ycoordinate # gives 2P. 
>  # Example: let's add P3 to itself. 
>  # the slope of the tanget of C at P3 is obtained by
# implicitly differentiating the equation for C. # So y^2=x^3+73 differentiated implicitly gives # 2y dy = 3x^2 dx, i.e. # dy/dx = 3/2 x^2/y. # Plugging in the coordinates of P3=(4,3) gives # dy/dx at P3 = 3/2 * 16/(3) = 8. # The equation of the langent line is therefore # 8 * (x+4) 3 
>  T := plot(8 * (x+4) 3,x=5..5,y=12..12): 
>  display(C,T,P3); 
>  # Let us find the "third" intersection point.
# note that we have to take the # negative branch 
>  solve(sqrt(g(x))((8)*(x+4)3),x); 
>  # So, the third point is at (72,?)

>  simplify(eval(sqrt(g(x)),x=72)); 
>  # OK the point is (72,611)

>  P4 := pointplot({[72,611]}); 
>  display([C,P3,P4,T]); 
>  T := plot(8 * (x+4) 3,x=20..75,y=650..650): 
>  C := plot([sqrt(g(x)),sqrt(g(x))],x=20..75,y=650..650): 
>  display(C,T,P4); 
>  P4negative := pointplot({[72,611]}); 
>  display(C,T,P3,P4negative); 
>  # thus we have computed 2*P3 
>  # In general, if the curve E is given by
# y^2=x^3+bx+c # and if P1 = (x1,y1), P2=(x2,y2) # then P3 = (x3,y3) where # x3 = m^2  x1x2 # y3 = m(x1x3)y1 # and # m= (y2y1)/(x2x1) if P1 not equal P2 # and # m = (3*x1^2+b)/(2*y1) if P1 = P2. # If the slope m is infinite then P3 = infinity # Also, infinity + P = P for all points P. # This addition is associative, # infinity is the identity element, and # the inverse of P=(x,y) is P=(x,y). # Thus we have a group. # The group is abelian, as P+Q = Q+P # (as can be seen from the fact that the formulae # are symmetric in x and y (up to a minus sign # which cancels). # Thus we have an abelian group. 
> 