Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
22 views
ubuntu2204
Kernel: SageMath 10.1
x,y,l=var('x','y','l') # x = Red Divisions # y = Blue Divisions # l = Blue advantage in effectiveness(lambda) l=3.0 # given lambda x_0=5.0 # initial red y_0=2.0 # initial blue deltat=0.1 # time step w=.9 # given w dxdt(x,y)=-l*w*.05*y-l*.005*x*y dydt(x,y)=-w*.05*x-.005*x*y War=[] data=[[0,x_0,y_0]] #initial (t,x,y) t=0 x=x_0 y=y_0 for i in range(100000): deltax=dxdt(x,y)*deltat deltay=dydt(x,y)*deltat t+=deltat x+=deltax y+=deltay data.append([t,x,y]) if x<0: War.append([round(l,1),"Blue",round(t,2),y]) break if y<0: War.append([round(l,1),"Red",round(t,2),x]) break display(table(War,header_row=["$\\lambda$","Winner", "Time","Troops"]))

a) Red wins in 39 days with 2.79 troops remaining

b)

w=.1: Red wins in 102.1 days with 1.36 troops remaining

w=.2: Red wins in 48.9 days with 2.074 troops remaining

w=.5: Red wins in 19.5 days with 2.804 troops remaining

w=.75: Red wins in 13 days with 3.026 troops remaining

w=.9: Red wins in 10.9 days with 3.106 troops remaining

c) As we saw in the last question as the weather got better Red won in fewer days. Thus meaning Blue benefits from adverse weather, and you bshould expect Red to attack on a sunny day.