Ask Your Question

Revision history [back]

I'm running across some strange syntax error that hasn't occured before I threw the cos function into the differential equation. Below is the code and the error:

x,t = var('x,t') plot1 = plot_slope_field(5x-.3x^2-2(1+cos(pit)),(t,0,10),(x,0,20),headaxislength=3,headlength=3,axes_labels=['$Time$','$Fish Pop.$'],title="No Harvesting",fontsize=13) x = function('x')(t) soln = lambda c:desolve_rk4(diff(x,t)==5x-.3x^2-2(1+cos(pit),x,ics=[0,c],end_points=[0,10],ivar=t,step=0.1) plot2 = lambda c, color:list_plot(soln(c),plotjoined=True,axes_labels=['$Time$','$Fish Pop.$'],thickness=2,color=color) show(plot1+sum(plot2(c,color=tuple(colormaps.hsv(1-c/13)[:3])) for c in [1,3.25,5.5,7.75,10]),ymin=0,ymax=20)

File "<ipython-input-27-1dec6aa982e7>", line 6 plot2 = lambda c, color:list_plot(soln(c),plotjoined=True,axes_labels=['$Time$','$Fish Pop.$'],thickness=Integer(2),color=color) ^ SyntaxError: invalid syntax

*The carrot was pointing at the "2" of "plot2"

Please help.

I'm running across some strange syntax error that hasn't occured before I threw the cos function into the differential equation. Below is the code and the error:

Here is the code

x,t = var('x,t')
plot1 = plot_slope_field(5x-.3x^2-2(1+cos(pit)),(t,0,10),(x,0,20),headaxislength=3,headlength=3,axes_labels=['$Time$','$Fish plot_slope_field(5*x-.3*x^2-2(1+cos(pi*t)),(t,0,10),(x,0,20),headaxislength=3,headlength=3,axes_labels=['$Time$','$Fish Pop.$'],title="No Harvesting",fontsize=13)
x = function('x')(t)
soln = lambda c:desolve_rk4(diff(x,t)==5x-.3x^2-2(1+cos(pit),x,ics=[0,c],end_points=[0,10],ivar=t,step=0.1)
c:desolve_rk4(diff(x,t)==5*x-.3*x^2-2(1+cos(pi*t),x,ics=[0,c],end_points=[0,10],ivar=t,step=0.1)
plot2 = lambda c, color:list_plot(soln(c),plotjoined=True,axes_labels=['$Time$','$Fish Pop.$'],thickness=2,color=color)
show(plot1+sum(plot2(c,color=tuple(colormaps.hsv(1-c/13)[:3])) for c in [1,3.25,5.5,7.75,10]),ymin=0,ymax=20)

[1,3.25,5.5,7.75,10]),ymin=0,ymax=20)

File "<ipython-input-27-1dec6aa982e7>", line 6 plot2 = lambda c, color:list_plot(soln(c),plotjoined=True,axes_labels=['$Time$','$Fish Pop.$'],thickness=Integer(2),color=color) ^ SyntaxError: invalid syntax

syntax

*The carrot was pointing at the "2" of "plot2"

Please help.