Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Writing code in Notepad and copy pasting to SageMath

So I'm trying my best to get the indent right everywhere, but sometimes I get the error that the indent is not right somewhere and also I get the error that I use some undefined name n_points; I have even tried typing the whole code into Sage myself, but then if I copy it from there and paste it in the notepad, it still includes all the dots. Even if I delete those dots, Sage still does not get happy when I copy and paste the code after only removing the dots via the notepad.... This is my code

def ell_geom_animation(E,init_points,n_points=10):
      var('x,y')
      #E = EllipticCurve(y^2==x^3-82*x);
      p = init_points
      j = len(p)
      ell_frames = [plot(E)]*(n_points+j)
      point_plots = []
      line_plots = []
      point_frames = []
      line_frames = []
for i in srange(0,j-1):
    point_plots += point(p[i][0:2],color='black',size=10)

 for i in srange(0,n_points):
     p += [E(p[i]+p[i+1])]
     point_plots += point(p[j+i][0:2],color='black',size=10)
     point_frames.append(point_plots)
     line_plots += line([p[i][0:2],p[i+1][0:2]],color='black',size=10)
     line_frames.append(line_plots)

 A1 = animate(ell_frames)
 A2 = animate(point_frames)
 A3 = animate(line_frames)
 return show(A1+A2+A3) # superimpose frame

Does anyone have some idea what is wrong with the alignments and maybe have a suggestion where I can write my code better such that I can simply copy and paste it in SageMath and press enter. I would very much appreciate suggestions and help.

Writing code in Notepad and copy pasting to SageMath

So I'm trying my best to get the indent right everywhere, but sometimes I get the error that the indent is not right somewhere and also I get the error that I use some undefined name n_points; I have even tried typing the whole code into Sage myself, but then if I copy it from there and paste it in the notepad, it still includes all the dots. Even if I delete those dots, Sage still does not get happy when I copy and paste the code after only removing the dots via the notepad.... This is my code

def ell_geom_animation(E,init_points,n_points=10):
      var('x,y')
      #E = EllipticCurve(y^2==x^3-82*x);
      p = init_points
      j = len(p)
      ell_frames = [plot(E)]*(n_points+j)
      point_plots = []
      line_plots = []
      point_frames = []
      line_frames = []
for i in srange(0,j-1):
    point_plots += point(p[i][0:2],color='black',size=10)

 for i in srange(0,n_points):
     p += [E(p[i]+p[i+1])]
     point_plots += point(p[j+i][0:2],color='black',size=10)
     point_frames.append(point_plots)
     line_plots += line([p[i][0:2],p[i+1][0:2]],color='black',size=10)
     line_frames.append(line_plots)

 A1 = animate(ell_frames)
 A2 = animate(point_frames)
 A3 = animate(line_frames)
 return show(A1+A2+A3) # superimpose frame

Does anyone have some idea what is wrong with the alignments and maybe have a suggestion where I can write my code better such that I can simply copy and paste it in SageMath and press enter. enter? I would very much appreciate suggestions and help.