# Maple code for Newton Cooling maple lab 2, S2010 # #Notes on L2.1 # maple integral table lookup unassign('k','omega','t','x'); integrand:=(35-14*cos(omega*(x-3)))*k*exp(k*x-k*t); F:=unapply(integrand,(x,t,k,omega)); int(F(x,t,k,omega),x=0..t); # Test LHS=RHS for u'+ku=kA. # Test LHS=RHS for u'+ku=kA. unassign('t','u0','omega','k'): uh:=u0*exp(-k*t): up:=(explicit answer from L2.1): myANS:=uh+up: LHS:=diff(myANS,t)+k*myANS: RHS:=k*(35-14*cos(omega*(t-3))): simplify(expand(LHS-RHS)); #Notes on L2.2 # Extract steady-state solution expr:=(myANS from L2.1): SS:=subs(exp(-k*t)=0,exp(-2*k*t)=0,expr); #Notes on L2.3 unassign('t','u0','k','omega'): AA:=unapply(35-14*cos(omega*(t-3)),(t,omega)); uss:=35-(14*k/(k^2+omega^2))*(k*cos(omega*(t-3))+omega*sin(omega*(t-3))): uss0:=subs(t=0,uss); U:=unapply((u0-uss0)*exp(-k*t)+uss,(t,u0,k,omega)): plot({U(t,76,0.32,Pi/12),AA(t,Pi/12),21},t=0..48); plot(sin(x),x=0..Pi,color=black); #Notes on L2.4 with(plots): unassign('t','u0','k','omega'): uh:=u0*exp(-k*t): up:=(the answer from L2.1): myANS:=uh+up: U:=unapply(myANS,(t,u0,k,omega)); implicitplot(U(t,76,k,Pi/12)=30,t=0..72,k=0.2..0.48); plot3d({U(t,76,k,Pi/12),30},t=0..72,k=0.2..0.48);