Question: help with if then else

Hello,

I am tring to do if–then–else in the do-loop for the parameter A[1]. Example: when k=3 we want to use A[1]=B[3] insted of B[1] but it seems my if–then–else did not do what I want. Any ideas?

Thank you

This is maple code:

> restart;
> k := 0; B[1] := 0.001/365: B[2] :=0.002/365:B[3] :=0.005/365:
> ode := diff(U(t), t) = -(A[1]+A[2]*U(t))*U(t);
> ic[0] := U(365*k) = 1000;
> sol[0] := dsolve({ic[0], subs(A[1] = B[1], A[2] = B[2], ode)}, U(t), numeric);
> sigma := .5;
> for k to 4 do 
if k = 3 then A[1] = B[3] else A[1] = B[1] end if; 
tk := 365*k; 
V := rhs(sol[k-1](tk)[2]); 
ic[k] := U(tk) = sigma*V; 
sol[k] := dsolve({ic[k], subs(A[1] = B[1], A[2] = B[2], ode)}, U(t), numeric)
 end do;
Please Wait...