On Wed, Jan 28, 2009 at 9:05 AM, David Møller Hansen <da...@mollerhansen.com> wrote: > > Hi > > I've made an interact on elliptic curve point addition, see below. > When I run it in notebook() mode I get an error: > > Traceback (click to the left for traceback) > ... > AttributeError: 'SymbolicEquation' object has no attribute > '_fast_float_' > > It worked in sage 3.1.1. I can't figure out how to fix it. Help is > much appreciated since I want to add this to the wiki and my thesis > presentation. >
Hi, Even using "Show Original" the code below is too mangled by email to work. Try it? Pull up your sent email and paste the code into sage. You should send your code as an email attachment (e.g., a sws file, or just paste your code into a .txt file and attach), or post it online e.g., pastebin and post a link to that. William > ______________ > > def point_txt(P,name,rgbcolor): > if (P.xy()[1]) < 0: > r = text(name,[float(P.xy()[0]),float(P.xy() > [1])-1],rgbcolor=rgbcolor) > elif P.xy()[1] == 0: > r = text(name,[float(P.xy()[0]),float(P.xy()[1]) > +1],rgbcolor=rgbcolor) > else: > r = text(name,[float(P.xy()[0]),float(P.xy()[1]) > +1],rgbcolor=rgbcolor) > return r > > E = EllipticCurve('37a') > list_of_points = E.integral_points() > html("Graphical addition of two points $P$ and $Q$ on the curve $ E: > %s $"%latex(E)) > @interact > def _(P=selector(list_of_points,label='Point P'),Q=selector > (list_of_points,label='Point Q'), marked_points = checkbox > (default=True,label = 'Points'), Lines = selector([0..2],nrows=1), > Axes=True): > curve = plot(E,rgbcolor = (0,0,1),xmin=25,xmax=25) > #Q = list_of_points[Q] > #P = list_of_points[P] > R = P + Q > Rneg = -R > #html("$P=(%s:%s:%s)$, $Q=(%s:%s:%s)$\n"%(latex(P[0]),latex(P > [1]),latex(P[2]),latex(Q[0]),latex(Q[1]),latex(Q[2]))) > #html("Graphical addition of points $P$ and $Q$ \non the curve $ E: > %s $ \n\n$P + Q = (%s:%s:%s)$"%(latex(E),latex(R[0]),latex(R[1]),latex > (R[2]))) # $P + Q$ = $%s + %s = %s"%(P,Q,R) > l1 = line_from_curve_points(E,P,Q) > l2 = line_from_curve_points(E,R,Rneg,style='--') > p1 = point(P,rgbcolor=(1,0,0),pointsize=40) > p2 = plot(Q,rgbcolor=(1,0,0),pointsize=40) > p3 = plot(R,rgbcolor=(1,0,0),pointsize=40) > p4 = plot(Rneg,rgbcolor=(1,0,0),pointsize=40) > textp1 = point_txt(P,"$P$",rgbcolor=(0,0,0)) > textp2 = point_txt(Q,"$Q$",rgbcolor=(0,0,0)) > textp3 = point_txt(R,"$P+Q$",rgbcolor=(0,0,0)) > if Lines==0: > g=curve > elif Lines ==1: > g=curve+l1 > elif Lines == 2: > g=curve+l1+l2 > if marked_points: > g=g+p1+p2+p3+p4 > if P != Q: > g=g+textp1+textp2+textp3 > else: > g=g+textp1+textp3 > g.axes_range(xmin=-5,xmax=5,ymin=-13,ymax=13) > show(g,axes = Axes) > > def line_from_curve_points(E,P,Q,style='-',rgb=(1,0,0),length=25): > """ > P,Q two points on an elliptic curve. > Output is a graphic representation of the straight line intersecting > with P,Q. > """ > # The function tangent to P=Q on E > if P == Q: > if P[2]==0: > return > line([(1,-length),(1,length)],linestyle=style,rgbcolor=rgb) > else: > # Compute slope of the curve E in P > l=-(3*P[0]^2 + 2*E.a2()*P[0] + E.a4() - > E.a1()*P[1])/((-2)*P[1] - > E.a1()*P[0] - E.a3()) > f(x) = l * (x - P[0]) + P[1] > return > plot(f(x),-length,length,linestyle=style,rgbcolor=rgb) > # Trivial case of P != R where P=O or R=O then we get the vertical > line from the other point > elif P[2] == 0: > return line([(Q[0],-length),(Q > [0],length)],linestyle=style,rgbcolor=rgb) > elif Q[2] == 0: > return line([(P[0],-length),(P > [0],length)],linestyle=style,rgbcolor=rgb) > # Non trivial case where P != R > else: > # Case where x_1 = x_2 return vertical line evaluated in Q > if P[0] == Q[0]: > return line([(P[0],-length),(P > [0],length)],linestyle=style,rgbcolor=rgb) > > #Case where x_1 != x_2 return line trough P,R evaluated in Q" > l=(Q[1]-P[1])/(Q[0]-P[0]) > f(x) = l * (x - P[0]) + P[1] > return plot(f(x),-length,length,linestyle=style,rgbcolor=rgb) > > > > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---