CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Project: exam 2
Views: 21
Image: ubuntu2204
Kernel: SageMath 10.1

6.8 last whale problem ♡\heartsuit

x,y=var('x,y') #x = Blue Whales #y = Fin Whales #E = Fishing days or something #a = Alpha #lam=4.0 x0=5000 #Initial blue y0=70000 #Initial fin deltat=1 #time step a = 10^(-6) #alpha E=5100 Ev=0 dxdt(x,y)=.05*x*(1-(x/150000))-a*x*y-10^(-5)*E*x dydt(x,y)=.08*y*(1-(y/400000))-a*x*y-10^(-5)*E*y streams=streamline_plot((dxdt(x,y),dydt(x,y)), (x,0,400000),(y,0,500000)) display(streams) whale_war=[] #lam=1.0 while Ev <= 1000: data=[[0,x0,y0]] #initial (t,x,y) t=0 x=x0 y=y0 for i in range(10000): deltax=dxdt(x,y,Ev)*deltat deltay=dydt(x,y,Ev)*deltat t+=deltat x+=deltax y+=deltay data.append([t,x,y]) if abs(deltax) < .1 and abs(deltay) < .5: whale_war.append([Ev, t, x, y]) break Ev+=100 #display(table(whale_war)) display(table([data[-1]],header_row=["time","Blue","Fin"]))
Image in a Jupyter notebook