[sage-support] Re: different result from file or at prompt
Justin, that is right. "return" caused a graph to be drawn. Now that you pointed out why it didn't work, I see another solution: graph = complex_plot(g, (-3, 3), (-3, 3)) graph.show() which doesn't require a return statement; since my original intention was to put the drawing command inside a loop and draw a lot of graphs, I'll need to do it with "show" rather than "return". Thank you. Michael On Tuesday, November 13, 2018 at 8:38:52 PM UTC-8, Michael Beeson wrote: > > def nov13(): > var('M,N,z') > f = (M^2-3*N)*(-i *sqrt(3)-1) *z^3 > f = f + (M^2 *(-i *sqrt(3) +3) + 3*N*(-i *sqrt (3) - 1))*z^2 > f = f + (M^2 *(i *sqrt(3)+3) + 3*N* (i* sqrt(3)-1))*z + (M^2-3*N)* (i* > sqrt(3)-1) > g = f.substitute(M=6,N=11) > complex_plot(g, (-3, 3), (-3, 3)) > > if this code is put in a file and the file is "attached" I get no plot, > but if > I paste the function body in to a prompt then I do get a (very nice) plot. > > I expected it would run from an attached file, which is how I usually use > SageMath. > Can someone explain why I don't get a plot that way? > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: graphic array fontsize
In sagemath-8.5beta3, I got it working after deleting all figsize and fontsize in all subplot @interact def _(t0=0, q0=1e-6, I0=0, L=slider(1e-3,1e0,0.01,12e-2), C=slider(1e-9,1e-5,1e-7, 1.5e-6),tmax=1e-2): p1 = plot(q_LC(t0=t0, q0=q0, I0=I0, L=L, C=C), (t,0,tmax), color='blue') p2 =plot(q_I(t0=t0, q0=q0, I0=I0,L=L, C=C), (t,0,tmax), color='red') g = graphics_array([p1, p2]); g.show(frame=True,figsize=[6,2]) On github I view the file : https://github.com/ictus5d/asa/blob/master/14-11-rlc.ipynb Le jeudi 5 juillet 2018 11:00:32 UTC+2, HG a écrit : > > Hi, > > In this graphic the second graphic p2 doesn't modify fontsize=8, but if > I interchange it does, that means the second graphic is invalid to the > command. > > Any help ? > > Regards > > r=2/sqrt(n(pi)); > > p1=plot(circle((0,0),r,color="red",fill=True,alpha=0.2,fontsize=8)+\ > polygon(((-1,1),(1,1),(1,-1),(-1,-1)),color="blue",alpha=0.2, > thickness=1,frame=True,axes=True,fontsize=8));p2=c > g = graphics_array([p1,p2]); > g.show(frame=True,figsize=10,fontsize=8) > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: documentation?
Oops, "243" in my post should have been "k". I don't know how to edit a post after I've posted it. On Wednesday, November 14, 2018 at 10:31:34 PM UTC-8, Michael Beeson wrote: > > After quite some searching I did not succeed to find documentation for > sage functions to work with complex numbers as much as I would like. > For example if I have a complicated rational expression, how can I tell > Sage "bring this to the form a + bi". It seems real() and imag() only > work > if no pre-processing is needed. How about "multiply numerator and > denominator by denominator.conjugate()" ? There's probably a chapter in > the documentation about this, could someone please point me to it, I > seem to be incompetent at finding it, sorry. > > Since people want something concrete to look at, not just a general > question, here is some code. You'll see that it computes a certain > complex function (actually two of them) > with integer parameters N and M, the solution(s) of a certain equation. > I'd like to compute that the absolute value of those expressions must be 1. > The > code below computes it numerically for some more or less random values of > N and M, and it is 1. for those values, but I can't figure out how to > compute it symbolically. Also, if there's a better way to do polynomial > division than I've used below, please tell me. > > def nov13b(): > var('p,q,r,N,M,x') > a = sqrt(3)/2 > b = (x-x^(-1))/(2*i) > c = (sqrt(3)/2)* (x+x^(-1))/2 + (1/2)*(x-x^(-1))/(2*i) > X = (M/3)*(a+b+c) > f = 24*(X^2-N*b*c)*x^2 > g = (f.maxima_methods().divide(x+1)[0]).full_simplify() > print(g.full_simplify()) > print("") > t = exp(-pi*i/3) > print(g(x=t).full_simplify()) > print("") > h = (g.maxima_methods().divide(x-t)[0]).full_simplify() > print("h = ") > print(h) > print("") > answers = solve(h,x) > assume(N,'integer') > assume(M,'integer') > for u in answers: > print("") > ans = u.rhs().simplify() > for k in range(230,245): > ans_numerical = abs(ans.substitute(M=11,N=243)).simplify() > print(n(ans_numerical)) > > > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] documentation?
After quite some searching I did not succeed to find documentation for sage functions to work with complex numbers as much as I would like. For example if I have a complicated rational expression, how can I tell Sage "bring this to the form a + bi". It seems real() and imag() only work if no pre-processing is needed. How about "multiply numerator and denominator by denominator.conjugate()" ? There's probably a chapter in the documentation about this, could someone please point me to it, I seem to be incompetent at finding it, sorry. Since people want something concrete to look at, not just a general question, here is some code. You'll see that it computes a certain complex function (actually two of them) with integer parameters N and M, the solution(s) of a certain equation. I'd like to compute that the absolute value of those expressions must be 1. The code below computes it numerically for some more or less random values of N and M, and it is 1. for those values, but I can't figure out how to compute it symbolically. Also, if there's a better way to do polynomial division than I've used below, please tell me. def nov13b(): var('p,q,r,N,M,x') a = sqrt(3)/2 b = (x-x^(-1))/(2*i) c = (sqrt(3)/2)* (x+x^(-1))/2 + (1/2)*(x-x^(-1))/(2*i) X = (M/3)*(a+b+c) f = 24*(X^2-N*b*c)*x^2 g = (f.maxima_methods().divide(x+1)[0]).full_simplify() print(g.full_simplify()) print("") t = exp(-pi*i/3) print(g(x=t).full_simplify()) print("") h = (g.maxima_methods().divide(x-t)[0]).full_simplify() print("h = ") print(h) print("") answers = solve(h,x) assume(N,'integer') assume(M,'integer') for u in answers: print("") ans = u.rhs().simplify() for k in range(230,245): ans_numerical = abs(ans.substitute(M=11,N=243)).simplify() print(n(ans_numerical)) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.