2020-03-01 08:36:16 +0200 asked a question implicit_plot leaves out points I'm trying to use implicit_plot to graph nullclines for a competition model, but only some parts of the nullclines are plotted. I have: var("N,P") Nprime(N,P) = N*(3-N-2*P) implicit_plot(Nprime, (N,0,3), (P,0,3))  Clearly, this function is 0 at all points where N=0, but the graph only shows them up to P=3/2. Is there anything I can do to avoid this or is it a bug in implicit_plot? 2019-09-13 19:27:33 +0200 received badge ● Famous Question (source) 2018-03-17 15:55:58 +0200 received badge ● Famous Question (source) 2018-01-24 22:18:38 +0200 received badge ● Famous Question (source) 2017-08-11 20:29:26 +0200 received badge ● Popular Question (source) 2017-07-19 22:15:21 +0200 received badge ● Famous Question (source) 2017-03-01 23:16:03 +0200 received badge ● Nice Question (source) 2017-02-22 21:02:01 +0200 received badge ● Popular Question (source) 2017-02-22 21:02:01 +0200 received badge ● Notable Question (source) 2017-01-01 22:32:36 +0200 commented answer Using desolve_odeint with external stimulus Thanks. Is there a way to incorporate something like a square wave into an ODE in Sage without using Python functions? 2016-12-31 22:54:09 +0200 asked a question Using desolve_odeint with external stimulus I'm trying to numerically solve a two-variable system of differential equations with a periodic external driver (square wave). Right now, the code I have is: from scipy.signal import square def sqstim(t, amp=1): return (amp/2)*float(square(t))+amp/2 var("V,w") trange=srange(0,100,0.1) def eqns(t): return [1/100*(-w+(V^3-V)+sqstim(t)), V-0.2*w] sol=desolve_odeint(eqns, times=trange, ics=[0.1,0.1], dvars=[V,w])  This gives "TypeError: 'function' object is not iterable". What should I do instead? 2016-12-05 08:23:44 +0200 received badge ● Famous Question (source) 2016-10-09 18:35:37 +0200 received badge ● Popular Question (source) 2016-10-09 18:35:37 +0200 received badge ● Notable Question (source) 2016-07-16 18:21:37 +0200 received badge ● Popular Question (source) 2016-07-16 18:21:37 +0200 received badge ● Notable Question (source) 2016-05-10 19:29:02 +0200 received badge ● Notable Question (source) 2015-12-19 12:51:45 +0200 received badge ● Notable Question (source) 2015-10-06 02:37:44 +0200 received badge ● Notable Question (source) 2015-09-26 18:10:39 +0200 received badge ● Popular Question (source) 2015-09-03 19:45:28 +0200 answered a question Finding solutions as numerical values rather than equations I would use: sol=solve(x^2-4==0,x) [eq.rhs() for eq in sol]  The .rhs() method extracts the right-hand side of an equation. 2015-09-03 08:39:03 +0200 commented question Code disappears in notebook Is it whole cells that disappear or pieces of code within cells? 2015-09-03 07:57:06 +0200 asked a question SageMathCloud Clickable Interact Doesn't Work I'm trying to run the sample clickable interact given by William Stein at http://permalink.gmane.org/gmane.comp..., but nothing happens when I click on the image. The code is @interact def f0(fun=x*sin(x^2), mousemove='', click='(0,0)'): click = sage_eval(click) g = plot(fun, (x,0,5), zorder=0) + point(click, color='red', pointsize=100, zorder=10) ymax = g.ymax(); ymin = g.ymin() m = fun.derivative(x)(x=click[0]) b = fun(x=click[0]) - m*click[0] g += plot(m*x + b, (click[0]-1,click[0]+1), color='red', zorder=10) def h(p): f0.mousemove = p def c(p): f0(click=p) show(g, events={'click':c, 'mousemove':h}, svg=True, gridlines='major', ymin=ymin, ymax=ymax)  Also, what is p in this code? Is there any documentation on clickable interacts in SMC? 2015-04-08 16:16:39 +0200 received badge ● Notable Question (source) 2015-03-11 00:59:31 +0200 received badge ● Notable Question (source) 2015-02-23 04:44:20 +0200 received badge ● Popular Question (source) 2014-12-24 21:42:00 +0200 asked a question Interacts not working in IPython notebook I'm running Sage 6.4.1 (on Ubuntu 14.04 and Firefox 34.0) and using the IPython notebook. It's a great interface, but interactives aren't working. For example, the following brings up a bunch of HTML rather than an actual interactive. @interact def test(a=(-3,3)): p=plot(a*sin(x), (x,-2*pi, 2*pi)) show(p)  Do interactives work differently in the IPython notebook? 2014-08-06 15:23:52 +0200 received badge ● Nice Question (source) 2014-08-06 15:23:49 +0200 received badge ● Popular Question (source) 2014-06-29 21:12:54 +0200 received badge ● Famous Question (source) 2014-06-29 21:12:54 +0200 received badge ● Notable Question (source) 2014-06-29 21:12:54 +0200 received badge ● Popular Question (source) 2014-06-29 20:55:45 +0200 received badge ● Famous Question (source) 2014-06-29 20:55:45 +0200 received badge ● Notable Question (source) 2014-06-29 20:55:45 +0200 received badge ● Popular Question (source) 2014-06-29 17:55:26 +0200 received badge ● Famous Question (source) 2014-06-29 17:55:26 +0200 received badge ● Notable Question (source) 2014-06-29 17:55:26 +0200 received badge ● Popular Question (source) 2014-06-29 03:15:52 +0200 marked best answer Strange type error in interactive I'm trying to make a simple interactive for my students to practice differentiating polynomials. For some reason, when an answer is entered, Sage tries to convert it (a polynomial) to an instance of sage.structure.parent.Parent and chokes. The same code run outside of an interactive works fine. Why is Sage trying to do this conversion and how do I get it to stop? #Create polynomial generator poly.=PolynomialRing(QQ) #Problems correct (in a row and total) streak = 0 tot = 0 first = True @interact def polyDiff(ans=input_box(label="f'(x)=", type=sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint)): #Load persistent variables global streak global tot global first global poly #Set up and display problem on first run if (first == True): rand_poly=poly.random_element(2) first = False html("f(x)=")+html(rand_poly) #Define correct answer corr = diff(rand_poly, x) #Check student's answer if (ans is not None): if (corr == ans): print "Correct!" tot += 1 streak += 1 #Generate new problem rand_poly = poly.random_element(5) else: html("Try again") streak = 0 else: print "Enter your answer"  2014-06-29 03:15:37 +0200 marked best answer Can't Install R Packages in Sage I'm running Sage 5.8 on Ubuntu 12.10 and am trying to install some R packages within Sage. However, when I enter %r install.packages("deSolve")  I get a green line and nothing happens. I am not asked what repository I'd like to use; when I specified a repository, I still got a green line and nothing happened. If I leave out the package name, I get a pop-up asking what package I want to install but nothing after that. What should I do? 2014-06-29 03:12:49 +0200 marked best answer Plotting Grid Graph I'm trying to plot a grid graph, specifying exactly where vertices should be plotted. (I want the plot to look like an actual grid and later overlay a graphics object on it.) The following code gives a KeyError: G=graphs.GridGraph([8,12]) pos_list=[(i,j) for i in range(8) for j in range(12)] pos_dict={} for i in range(len(pos_list)): pos_dict[i]=pos_list[i] G.show(pos=pos_dict)  How can I get my plot to look like a regular grid? 2014-06-29 03:12:48 +0200 marked best answer Using layout option with auto_update=false I'm writing an interactive and want the two pull-down menus and the update button to all appear in one row. @interact(layout={'top': [["ansA", "ansB"]]})works fine but doesn't show the update button. How do I include it in the layout? 2014-05-05 14:18:30 +0200 received badge ● Editor (source) 2014-05-05 14:18:30 +0200 edited question Linear Transformation Matrix is Transposed I define a linear transformation object using the following syntax: def f(v): l1 = [2*v[0]+3*v[1], 5*v[0]-v[1]] v1 = vector(l1) return(v1) lf = linear_transformation(RR^2, RR^2, f) lf  The output includes the matrix [[2, 5], [3,-1]] instead of [[2,3], [5,-1]]. Is this a bug or am I doing something wrong? EDIT: Specifying side="right" doesn't help. 2014-05-05 14:17:17 +0200 commented answer Linear Transformation Matrix is Transposed Tried that. It doesn't work.