Question: Euler's Nummerical - Solving Second Order Differential Equation

Hello!

 

I'm currently trying to program Euler's Nummerical Method to solve a second order differential equation, that I've split into two parts: 

f1:=v:

f2:=-(0.006549/0.7038)*v-sin(x/1.03)*9.82

 

In an attempt to solve this equation by using Euler's in Maple, I typed in the following commands: 

 

EulerSystem:=proc (f1,f2,t0,x0,v0,h,n) local t,x,v,i,p;
t[0]:=0; x[0]:=x0; v[0]:=v0;
for i from 0 to (n-1) do;
x[i+1]:=x[i]+h*f1*(t[i],x[i],v[i]);
v[i+1]:=v[i]+h*f2*(t[i],x[i],v[i]);
t[i+1]:=t[i]+h;
p[i]:=plot([t[i+1],x[i+1]]);
end do:
plots[display](seq(p[i],i=0..n-1));
end proc:

 

f1:=(t,x,v) -> v:

f2:=(t,x,v) -> -(0.006549/0.7038)*v-sin(x/1.03)*9.82:

EulerSystem(f1,f2,0,55.1,0,0.05,1000)

 

This gives me the error: 

"Error, (in plot) unexpected option: 55.1+0.5e-1*v*(0,55.1,0)"

 

I've tried altering the plot-order a bit: " p[i]:=plot([[t[i],x[i]],[t[i+1],x[i+1]]]) " which only led to the error: 

"Error, (in plot) found points with fewer or more than 2 components".

 

Thanks a lot

 

Emil Frank
 

This has been branched into the following page(s):
Please Wait...