Homework set 8

Exercise 1

Differentialgleichungssystem={c'[t]==-s[t],s'[t]==c[t]};
Anfangsbedingungen={c[0]==1,s[0]==0};
NumerischeLoesung=NDSolve[{Differentialgleichungssystem,Anfangsbedingungen},{s,c},{t,0,100}];
Loesungs=Function[{t},Evaluate[NumerischeLoesung[[1,1,2]][t]]];
Loesungc=Function[{t},Evaluate[NumerischeLoesung[[1,2,2]][t]]];

Plot[{Loesungs[t],Loesungc[t]},{t,0,4π},PlotLabel->Style["Trajectory in the x-y plane",FontSize->14]]
Print["S(t=2)= ",Loesungs[2]]
Print["C(t=2)= ",Loesungc[2]]

Exercise 2

The idea of the exercise is to implement it yourself.
You may do that following the next example, which is the solution to the problem 6.3f), where we can see that the parametric plot of the solution is indeed always an ellipse.

k=1;
t0 = 0;
tf = 20;
Differentialgleichungssystem={px'[t]==-x[t],x'[t]== px[t],py'[t]==-y[t],y'[t]== py[t]};
Anfangsbedingungen={px[t0] ==0,x[t0]==1,y[t0]==0.4,py[t0]==0.1};
NumerischeLoesung=NDSolve[{Differentialgleichungssystem,Anfangsbedingungen},{x,px,y,py},{t,t0,tf}];
Loesungx=Function[{t},Evaluate[NumerischeLoesung[[1,1,2]][t]]];
Loesungy=Function[{t},Evaluate[NumerischeLoesung[[1,3,2]][t]]];
paramPlot =ParametricPlot[{Loesungx[t],Loesungy[t]},{t,t0,tf}, PlotLabel->Style["Trajectory plot in the x-y plane",FontSize->14],AspectRatio->1];
Animate[Show[paramPlot, Graphics[{PointSize[Large],Point[{Loesungx[t],Loesungy[t]}]}]],{t,t0,tf},AnimationRunning->False,AnimationRate->1]
Plot[Loesungx[t],{t,t0,tf},PlotLabel->Style["Plot of the trajectory in the x-plane, x(t)",FontSize->14]]
Plot[Loesungy[t],{t,t0,tf},PlotLabel->Style["Plot of the trajectory in the y-plane, y(t)",FontSize->14]]