2021-02-07 18:52:59 +0200 received badge ● Popular Question (source) 2021-01-13 10:19:14 +0200 received badge ● Notable Question (source) 2020-09-03 23:10:29 +0200 received badge ● Notable Question (source) 2020-07-11 06:52:55 +0200 received badge ● Popular Question (source) 2020-04-27 23:39:25 +0200 received badge ● Popular Question (source) 2019-11-13 21:24:14 +0200 asked a question Floyd's cycle and choosing smart indexing So I'm trying to implement something using Floyd's cycle. However, while there must be a solution, the while loop doesn't think so and I'm wondering why. This is my code: p=1013; g=3; h=245; G=[g]; a=[1]; b=[0]; a_found=0; def t_next(i,t): if t%3==0: G.append((G[i]*g)%p); elif t%3==1: G.append((G[i]*h)%p); else: G.append((G[i]^2)%p); def a_next(i,t): if t%3==0: a.append((a[i]+1)%p); elif t%3==1: a.append((a[i])%p); else: a.append((2*a[i])%p); def b_next(i,t): if t%3==0: b.append((b[i])%p); elif t%3==1: b.append((b[i]+1)%p); else: b.append((2*b[i])%p); i=1; c=1; while a_found != 1: n=i; for k in range(n,2*n+1): j=k-1; t_next(j,G[j]); a_next(j,G[j]); a b_next(j,G[j]); i+=1; if G[c]==G[2*c]: a_found=1; print [i,G[c],G[2*c],a[c],a[2*c],b[c],b[2*c]] else: c+=1;  The code contains three functions that compute new values of some values a, b and G which I store in a big list and compare two elements G[i] and G[2*i] in each round. Somehow, it never stops. And also I notice that I compute a lot of values multiple times and I don't know how to implement that better. I want to compute each time the values at indices 2 to 4, 3 to 6, 4 to 8, 5 to 10 and compare G[i] and G[2i]. But I guess I messed up the list G. Any suggestions are very welcome! 2019-11-13 21:02:54 +0200 asked a question While loop is neverending I have made a very simple version of some more difficult code I would like to have working. This is just to see what has gone wrong. I have the following:  f=1 while f!=0: n=f print n n=n+1%7 print n if n==0: print 'yes' else: f=f+1%7  Why doesn't it work that eventually f=0 and so the while loop stops? 2019-05-16 00:10:13 +0200 commented answer How to put background color behind animation Thanks, it works well. I have deleted the axes and only included a plain horizontal axis without scale. Also, I know have a green square, that looks the best imo. 2019-05-15 22:35:37 +0200 commented answer Putting label in the right spot (upper-left) during animation Yes, text would have been an option, but it's just a hassle sometimes to find the right spot (coordinates) for where to put that text. The plus and minus sign problem is solved in the other answer; this was not even a problem I noticed at first. But the code does the job now pretty well. 2019-05-15 22:31:36 +0200 commented answer Putting label in the right spot (upper-left) during animation This is even better indeed! I must say that I didn't even notice the plus- and minus sign changing at first. Nice solution! 2019-05-15 18:47:35 +0200 asked a question How to put background color behind animation So I read some of the questions and answers on this site but none of them got me a clear answer. I'm making an animation showing the group law of an elliptic curve. Anyways, I want it to look perfect so I simply need a positive colored background; I was thinking light green (maybe use hue). (Besides, where can I find a table that lists all the values of the hue colors without having to compute them myself?) My animation consists of a few frames played very slowly. My first frame is simply the curve. I had the idea to put it all in a big colored polygon to achieve the background. I could not find simple background color options for plots. This is my poor attempt: E = EllipticCurve(y^2==x^3+4*x^2-5*x+2); L = [(-6,-20),(-6,20),(6,20),(6,-20)]; frames = plot(E,xmin=-6,xmax=6,ymin=-20,ymax=20,color='red',thickness=3); frames += polygon(L,color=hue(0.40));  The problem is now that my plot is completely deformed... Of course, this looks very unpleasent. Anyone got an idea to deform the polygon such that the plot of this elliptic curve is nicely like it looks standard, as evaluating plot(E,xmin=-6,xmax=6,ymin=-20,ymax=20,color='red',thickness=3)? Oh, and also the color should be a bit more transparent. Thanks for the time. 2019-05-15 17:05:30 +0200 commented answer How to use Notepad++ for SageMath (or using vim) I use Ctrl+Q for comment and uncommenting blocks in Notepad++. 2019-05-15 00:15:03 +0200 received badge ● Nice Question (source) 2019-05-14 21:08:23 +0200 commented answer How to use Notepad++ for SageMath (or using vim) Oh, that makes me so happy! Such a simple solution and this is the end to my endless frustration of trying to manually put the right amount of spaces everywhere.... Thanks a lot!! 2019-05-14 16:15:20 +0200 asked a question How to use Notepad++ for SageMath (or using vim) After some research on this website, I have still not found a nice way to use an the editor Notepad++ for Sage. Is there some nice plug-in for this or do you use another editor for writing in Sage? I can't manually add tabs in Notepad++ because then the code looks awful in Sage since it places (multiple) ^I in front of lines of code. Thanks in advance for any help. 2019-05-14 13:34:19 +0200 commented answer Writing code in Notepad and copy pasting to SageMath Thanks for the suggestions! I have downloaded Notepad++ and after changing the settings by letting tabs be 4 spaces, it now works really well! 2019-05-13 23:58:47 +0200 received badge ● Scholar (source) 2019-05-13 23:57:35 +0200 received badge ● Supporter (source) 2019-05-13 23:10:07 +0200 received badge ● Student (source) 2019-05-13 22:20:06 +0200 asked a question 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. 2019-05-13 21:54:18 +0200 commented answer Putting label in the right spot (upper-left) during animation But then it is not a legend anymore :-/ 2019-05-13 20:29:16 +0200 received badge ● Editor (source) 2019-05-13 13:26:27 +0200 asked a question Putting label in the right spot (upper-left) during animation I'm quite new to SageMath. It took some time (half a sunday) to create a code the draws an elliptic curve with a cubic, controlling the speed of the animation and putting a label in. However, I don't know where I can put something like a legend_loc='upper left somewhere or whether that's even possible. My code is as follows: step=0.2; var('x,y'); a=animate([ plot(EllipticCurve(y^2==x^3+3.8*x^2-0.8*x+float(k)),xmin=-6,xmax=0 ,color="red",thickness=2,legend_label=r'$y^2=x^3+3.8x^2-0.8x+{}$'.format(float(k))) +plot(EllipticCurve(y^2==x^3+3.8*x^2-0.8*x+float(k)),xmin=10^(-9),xmax=6 ,color="red",thickness=2) + plot(x^3+3.8*x^2-0.8*x+float(k),xmin=-6,xmax=6,color="blue",thickness=1) for k in srange(-5,5,step)],xmin=-6,xmax=6,ymin=-20,ymax=20,gridlines=[[-6,6],[-20,20]]); a.show(delay=1)  I also tried set_legend_options(shadow=False, loc=2) in the plot function, but that doesn't satisfy SageMath either. Anyone an idea how I can put that label at some fixed spot? Btw, it would be even better if I could put that label on the top centre above the animation. I appreciate any suggestions and help.