Ask Your Question
0

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:

asked 2020-02-16 20:19:50 +0200

PolarizedIce gravatar image

updated 2020-02-16 20:52:14 +0200

vdelecroix gravatar image

Here is the code

x,t = var('x,t')
plot1 = 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)==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)

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-02-16 20:33:03 +0200

PolarizedIce gravatar image

I found my error, must have been an extra parenthesis somewhere.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-02-16 20:19:50 +0200

Seen: 175 times

Last updated: Feb 16 '20