# Explicit Euler method

• Jan 19th 2009, 08:46 PM
oxxiissiixxo
Explicit Euler method
Hi I want to write a program to solve these 2 ODEs, but I do know how to do it. Please help!

y'_1 = -y_1 + y_2
y'_2 = -100(y_2 - sin t) + cos t

t is from 0 to 1 and with inital value y_1= 1, y_2 = 2.

time step = 0.01
• Jan 19th 2009, 10:45 PM
Constatine11
Quote:

Originally Posted by oxxiissiixxo
Hi I want to write a program to solve these 2 ODEs, but I do know how to do it. Please help!

y'_1 = -y_1 + y_2
y'_2 = -100(y_2 - sin t) + cos t

t is from 0 to 1 and with inital value y_1= 1, y_2 = 2.

time step = 0.01

and what language are you expected to use?

.
• Jan 19th 2009, 11:06 PM
oxxiissiixxo
If possible, Matlab is prefer, but C is ok i think. Thanks!
• Jan 19th 2009, 11:34 PM
Constatine11
Quote:

Originally Posted by oxxiissiixxo
Hi I want to write a program to solve these 2 ODEs, but I do know how to do it. Please help!

y'_1 = -y_1 + y_2
y'_2 = -100(y_2 - sin t) + cos t

t is from 0 to 1 and with inital value y_1= 1, y_2 = 2.

time step = 0.01

Crude but should work:

Code:

```function rv=IODE   y=[1,2];   rv=[0,y];   dt=0.1;   for t=0:dt:1-dt       dydt=[y(1)+y(2),-100*(y(2)-sin(t))+cos(t)];       y=y+dt*dydt;       rv=[rv;[t+dt,y]];   end```
returns an array each row consists of the time and the y's

.
• Jan 19th 2009, 11:47 PM
oxxiissiixxo
thanks but I need to use the explicit euler method to solve this system
• Jan 20th 2009, 03:44 AM
Constatine11
Quote:

Originally Posted by oxxiissiixxo
thanks but I need to use the explicit euler method to solve this system

It is explicit, and it is Eulers method. It uses equation 68 from here

.