Q5.3-26E

Question

Use the Runge–Kutta algorithm for systems with = 0.1 to approximate the solution to the initial value problem.

x'=yz;x(0)=0,y'=-xz;y(0)=1,z'=-xy2;z(0)=1,

At t=1.

Step-by-Step Solution

Verified
Answer

The required result is: X1=0.803,Y1=0.59598,Z1=0.82316

1Given conditions

Given initial value problem is:

x'=yzy'=-xzz'=-xy2


And the initial conditions are:

x0=0y0=1z0=1

2Apply the Runge-Kutta method

To get the solution apply the Runge-Kutta method in mat lab for t=1.

 

Function n[t,x] = Runge_Kutta(f,t0,t_end,init_cond,h)
 %we begin at time t0 and end when we reach t_end
 %init_cond(i) contains the initial value of x_i
 %f contains functions such that x_i'=f_i(t,x1,x2,...)
 
 t(:,1)=t0; % t0 is the initial value of t
 x(:,1)=init_cond; % initial conditions are set
 
 i=1;
 while t(:,i) <t_end
 
     k1=f(t(i),x(:,i));
     k2=f(t(i)+0.5*h,x(:,i)+0.5*h*k1);
     k3=f(t(i)+0.5*h,x(:,i)+0.5*h*k2);
     k4=f(t(i)+h,x(:,i)+h*k3);
 
      x(:,i+1)=x(:,i)+(h/6)*(k1+2*k2+2*k3+k4);
 
     t(:,i+1)=t(:,i)+ h;
 i=i+1;
 
 end

clear all

 

init_cond=[0;1;1];

f=@(t,X) [X(2)*X(3);-X(1)*X(3);-X(1)*X(2)/2];

[t,x] = Runge_Kutta(f,0,1,init_cond,0.1);

 

table(t(:,end),x(1,end),x(2,end),x(3,end),'VariableNames',{'t','x','y','z'})

 

Then the results are;


T

X

Y

z

1

0.803

0.59598

0.82316


Therefore, X1=0.803,Y1=0.59598,Z1=0.82316.