1. ## 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

2. 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?

.

3. If possible, Matlab is prefer, but C is ok i think. Thanks!

4. 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

.

5. thanks but I need to use the explicit euler method to solve this system

6. 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

.