Write a function file that utilizes Eulers method to solve t

Write a function file that utilizes Euler\'s method to solve the following differential equation to within 10^-6 tolerance of the exact value. dx(t)/dt = 1.2 x - 0.6 xy dy (t)/dt = -0.8y + 0.3xy x(0) = 2, y(0) = 1

Solution

h=.1; % step\'s size
N=100; % number of steps
y(1)=1;
x(1)=2;
t(1)=0;
for n=1:N
x(n+1)= x(n)+h*(1.2*x(n)-.6*y(n)*y(n));
y(n+1)= y(n)+h*(-.8*y(n)+.3*y(n)*y(n));
t(n+1)=n*h;
end

 Write a function file that utilizes Euler\'s method to solve the following differential equation to within 10^-6 tolerance of the exact value. dx(t)/dt = 1.2 x

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site