restart: with(plots):harmo_euler := proc(t0,x0,v0,h,n,x,v,t)
local i;
x[0] := x0;
v[0] := v0;
t[0] := t0;
for i to n do
t[i]:=t[i-1]+h;
x[i]:=x[i-1]+h*v[i-1];
v[i]:=v[i-1]-h*x[i-1];
od;
end;harmo_runge := proc(t0,x0,v0,h,n,x,v,t)
local i;
x[0] := x0;
v[0] := v0;
t[0] := t0;
for i to n do
t[i]:=t[i-1]+h;
x[i]:=x[i-1]+h*(v[i-1]-h/2*x[i-1]);
v[i]:=v[i-1]-h*(x[i-1]+h/2*v[i-1]);
od;
end;harmo_euler(0,1,0,.126,50,x50,v50,t50);
harmo_euler(0,1,0,.0126,500,x500,v500,t500);
harmo_runge(0,1,0,.126,50,xr50,vr50,tr50);
harmo_runge(0,1,0,.0126,500,xr500,vr500,tr500);plot([[seq([t50[j],x50[j]],j=1..50)],[seq([t500[j*5],x500[j*5]],j=1..100)],[seq([t50[j],v50[j]],j=1..50)],[seq([t500[j*5],v500[j*5]],j=1..100)],cos(x),-sin(x)],x=0..2*Pi,y=-1.5..1.5,style=[point,point,point,point,line,line],color=[red,red,blue,blue,red,blue],resolution=1000,symbol=point);plot([[seq([tr50[j],xr50[j]],j=1..50)],[seq([tr500[j*5],xr500[j*5]],j=1..100)],[seq([tr50[j],vr50[j]],j=1..50)],[seq([tr500[j*5],vr500[j*5]],j=1..100)],cos(x),-sin(x)],x=0..2*Pi,y=-1.5..1.5,style=[point,point,point,point,line,line],color=[red,red,blue,blue,red,blue],resolution=1000,symbol=point);pendel := proc(t0,x0,v0,h,n,x,v,t)
local i;
x[0] := x0;
v[0] := v0;
t[0] := t0;
for i to n do
t[i]:=t[i-1]+h;
x[i]:=x[i-1]+h*(v[i-1] -h/2*sin(x[i-1]));
v[i]:=v[i-1]-h*sin(x[i-1]+h/2*v[i-1]);
od;
end;harmo_euler(0,0.1,0,.0126,500,xa1,va1,ta1);
harmo_euler(0,0.6,0,.0126,500,xa2,va2,ta2);
harmo_euler(0,1.1,0,.0126,500,xa3,va3,ta3);
harmo_euler(0,0.6,0,.0126,500,xa4,va4,ta4);
harmo_euler(0,2.1,0,.0126,500,xa5,va5,ta5);
harmo_euler(0,0.6,0,.0126,500,xa6,va6,ta6);
harmo_euler(0,3.1,0,.0126,500,xa7,va7,ta7);plot([
[seq([ta1[j],xa1[j]],j=1..500)],
[seq([ta2[j],xa2[j]],j=1..500)],
[seq([ta3[j],xa3[j]],j=1..500)],
[seq([ta4[j],xa4[j]],j=1..500)],
[seq([ta5[j],xa5[j]],j=1..500)],
[seq([ta6[j],xa6[j]],j=1..500)],
[seq([ta7[j],xa7[j]],j=1..500)]
],style=point,color=blue,resolution=1000,symbol=point);pendelarray := proc(start,steps,diff,xges,vges,tges)
local i,curr;
curr:=start;
for i to steps do
pendel(0,curr,0,.0126,1000,xges[i],yges[i],tges[i]);
curr:=curr+diff;
od;
end; pendelarray(0.1,120,.025,xges,vges,tges);
display(seq(plot([[seq([tges[1][j],xges[a][j]],j=1..1000)],(0.1+a*.025)*cos(x)],x=0..4*Pi,style=line,color=[blue,red],thickness=[2,1],resolution=2000,symbol=point,scaling=CONSTRAINED),a=1..120),insequence=true);display(seq(plot([[seq([tges[1][j],xges[a][j]],j=1..1000)],(0.1+a*.025)*cos(x)],x=0..4*Pi,style=line,color=[blue,red],thickness=[2,1],resolution=3000,symbol=point,scaling=CONSTRAINED,labels=["t","x(t)"],title="Pendel: Vergleich von allgemeiner L\366sung und Spezialfall mit harmonischer Schwingung",transparency=1,titlefont=[Helvetica,BOLD,12],labeldirections=[horizontal,vertical],axesfont=[Helvetica,normal,10],labelfont=[Helvetica,normal,10]),a=1..120),insequence=true);