Using Eulers Method

Thread Starter

Kayne

Joined Mar 19, 2009
105
Hi All,

Just wanted to check to see if I am doing this correctly

If the equation is

\(F(t) = m\ddot{y}+c\dot{y}+ky\)

\(\dot{y}(0) = 0\)

Where m = 1.5 c =190, k=28, F(t) = -500sin(10t)

I know that it has to be in the form of

\(yk+1 = yk+f(xk,yk)h\)

So solving Eulers method to 0.2 with a step size of 0.1


\( -500sin(10x)= 2\ddot{y}+180\dot{y}+25y\)

Now to change into for f(x,y) I have done the following

\(f(x,y) = -500sin(10x)-2\ddot{y}-180\dot{y}-25y\)

Is this the correct equation for f(x,y)??

So for i = 0

\(yk+1 = yk+f(xk,yk)h\)

\(y1 = yo+f(xo,yo)h\)

where
x0 = 0
y0 = 0
h = 0.1

This is where I think I have made a mistake becuase the two answers that I have found are very different from one another. I would like to know if I have done this correclty.

\(y1 = 0 + f(0, 0)0.1\)
\(y1 = 0 + f(-500sin(10*0)-2*0-180*0-25 )*0.1\)
\(y1 = -2.8\)

and for i = 1

\(y2 = y1+f(x1,y1)h\)

\(y1 = 1 + f(1, 1)0.2\)
\(y1 = 1 + f(-500sin(10*1)-2*1-180*1-25 )*0.2\)
\(y1 = -60.26tex]

Have I used eulers method correctly to solve for y1 = -2.5, y2 = -58.76

Thanks for your time\)
 
Last edited:

Thread Starter

Kayne

Joined Mar 19, 2009
105
These are the answer that I have found for the step increase of 0.1 to 0.5


\(y1 = 0 +f(0,0)0.1\)
\(y1 = 0 +f(-500sin(10*0) - 1.5*0 - 190*0 - 28)*0.1\)
\(y1 = -2.8\)

\(y2 = 1 + f(1,1)h\)
\(y2 = 1 +f(-500sin(10*1) - 1.5*1 - 190*0 - 28)*0.2\)
\(y2 =-60.26\)

\(y3 = 2 +f(2,2)0.3\)
\(y3 = 2 +f(-500sin(10*2) - 1.5*2 - 190*2 - 28)*0.3\)
\(y3 = -172.6\)

\(y4 = 3 + f(3.3)0.4\)
\(y4 = 3 +f(-500sin(10*3) - 1.5*3 - 190*3 - 28)*0.4\)
\(y4 =-338\)

\(y4 = 4 + f(4.4)0.5\)
\(y4 = 4 +f(-500sin(10*4) - 1.5*4 - 190*4 - 28)*0.5\)
\( y4 =-553.7\)

Can anyone confirm is these are correct please
 

t_n_k

Joined Mar 6, 2009
5,455
I'm not sure if your approach is correct. Normally one applies Euler's method to a first order differential equation - or in the case of an Nth order DE to a set of N individual 1st order DE's formulated as an 'equivalent' of the original Nth order equation.

In the case of a 2nd order DE you need 2 equations to perform the Euler numerical approximation.

So you have

\(m\ddot{y}+c\dot{y}+ky=F(t)\)

One follows a process like this ....

Let

\(z=\dot{y}\)

Hence

\(\dot{z}=\ddot{y}\)

Then form two first order Euler approximations with step h[sec]

\(z_{i+1}=z_i+f_1(t_i,y_i,z_i)*h\)

and

\(y_{i+1}=y_i+f_2(t_i,y_i,z_i)*h\)

\(f_1(t_i,y_i,z_i)=\frac{F(t_i)}{m}-\frac{c}{m}z_i-\frac{k}{m}y_i\)
\(f_2(t_i,y_i,z_i)=z_i\)

Then proceed with successive approximations given

\(\dot{y}(0)=0 \ y(0)=0 \ z(0)=0\)

I also think h=0.1 is too big a step size.
 
Last edited:

Thread Starter

Kayne

Joined Mar 19, 2009
105
I am not sure if I understand this correctly but here what I have done

\(z_{i+1}=z_i+f_1(t_i,y_i,z_i)*h\)

and

\(y_{i+1}=y_i+f_2(t_i,y_i,z_i)*h\)


So i = 0, h=0.1, x=0,y=0,z=0

\(z_{1}=0+f_1(t_0,y_0,z_0)*0.1\)

\(y_{1}=0+f_2(t_0,y_0,z_0)*0.1\)

So the equation is

\(f_1(t_0,y_0,z_0)= \frac{-500sin(10*x)-190z-28y}{1.5}\)

so

\(z_{1}=0+f_1(\frac{-500sin(10x)-190z-28y}{1.5})*0.1\)

\(z_{1}=0+f_1(\frac{-500sin(10*0)-190*0-28*0}{1.5})*0.1\)

\(z_1 = 0\)
and
\(y_{i+1} =y_1+f_2(t_0,y_0,z_0) \)

\(f_2(t_0,y_0,z_0) = z_i\)

zi = 0

\(y_{1}=0+f_2(0)\)

\(y_1 = 0\)

Now what I have found which make me think that I am incorrect is that when I find i = 1 , x,y,z all = 0 still.
 
Last edited:

t_n_k

Joined Mar 6, 2009
5,455
The value of h is not incremented with successive steps - it stays the same.

Also, I indicated that a step of h=0.1 [seconds] is too big to obtain a useful solution. This is based on a consideration of the incremental change in the forcing function F(t).

Presumably you want to find the value of y(t) at t=0.2 seconds. It would be good practice to do at least 10 steps from t=0 to 0.2 seconds. If you made a step size of h=0.02 seconds then going from t=0 to 0.2 seconds would involve 10 steps. Even then the approximation will be somewhat rough. One hundred steps would be better still. Doing it in just two steps is of little practical use. I realise doing even tens of steps with pen and paper would be laborious and error prone. I would think it would be best done using a computer based simulation. It can be readily done using a spreadsheet application - Excel for example.
 

Thread Starter

Kayne

Joined Mar 19, 2009
105
Ok I see where I have gone wrong with the step sizes. but still if I use the small step sizes then I end up with z = 0 and y=0, for i=0 and then when I go to i=1 the values for the equation are x,y,z =0 which again will give zero.

\(z_{i+1}=z_i+f_1(t_i,y_i,z_i)*h\)

and

\(y_{i+1}=y_i+f_2(t_i,y_i,z_i)*h\)


So i = 0, h=0.02, x=0,y=0,z=0

\(z_{1}=0+f_1(t_0,y_0,z_0)*0.02\)

\(y_{1}=0+f_2(t_0,y_0,z_0)*0.02\)

So the equation is

\(f_1(t_0,y_0,z_0)= \frac{-500sin(10*x)-190z-28y}{1.5}\)

so

\(z_{1}=0+f_1(\frac{-500sin(10x)-190z-28y}{1.5})*0.02\)

\(z_{1}=0+f_1(\frac{-500sin(10*0)-190*0-28*0}{1.5})*0.02\)

\(z_1 = 0\)

and
\(y_{i+1} =y_1+f_2(t_0,y_0,z_0) \)

\(f_2(t_0,y_0,z_0) = z_i\)

zi = 0

\(y_{1}=0+f_2(0)\)

\(y_1 = 0\)

so if I was to continue then the values are

i = 1, x = 0,y=0,z=0 from above.

I have missed something simple
 

t_n_k

Joined Mar 6, 2009
5,455
You still haven't got the method quite right.

y(0)=0, z(0)=0, h=0.02

f1(t,y,z)=-333.33*sin(10*t)-126.67*z-18.67*y
or
f1(t,y,z)=-(333.33*sin(10*t)+126.67*z+18.67*y)
f2(t,y,z)=z

y(0.02)=y(0)+f2(0,0,0)*h=0+0*0.02=0
z(0.02)=z(0)-(333.33*sin(10*0)+126.67*0+18.67*0)*0.02=0

y(0.04)=y(0.02)+f2(0.02,0,0)=0
z(0.04)=y(0.02)-(333.33*sin(10*0.02)+126.67*0+18.67*0)*0.02
or
z(0.04)=0-333.33*sin(0.2)*0.02=-1.324

y(0.06)=y(0.04)+z(0.04)*0.02=0-1.324*0.02=-0.02648
z(0.06)=z(0.04)-(333.33*sin(10*0.04)+126.67*(-1.324)+18.67*0)*0.02
or
z(0.06)=-1.324-(129.8-167.7)*0.02=-0.566

and so on ...
 
Top