Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey please help me solve and put this in Matlab Thanks here is the code that I am supposed to use: % 0 3 /

Hey please help me solve and put this in Matlab Thanks here is the code that I am supposed to use:
%03/04/2024
% Solve a 2nd order ODE example
% y''-2y'+ y = e^t/(1+t^2)
tspan =0:0.01:10;
y0=[1;0];
[t,y]= ode45(@ode1, tspan, y0);
figure(1)
plot(t,y(:,1))
% exact solution
ye = @(t) exp(t)-exp(t).*t-exp(t).*(-2*atan(t).*t + log(t.^2+1))/2;
hold on
plot(t,ye(t),'--','linewidth',2)
%
% max(abs(ye(t)-y(:,1)))
%% In class assignment:
% Solve following differential equations using MAPLE and MATLAB and compare
% your results.
%%(a) y''+2*y'+5*y=4*exp(-t)*cos(2*t), y(0)=1, y'(0)=0
tspan =0:0.01:10;
y0=[1;0];
[t,y]= ode45(@ode2, tspan, y0);
figure(2)
plot(t,y(:,1))
% exact solution
ye = @(t) exp(-t).*(2*t.*sin(2*t)+ sin(2*t)+2*cos(2*t))/2;
hold on
plot(t,ye(t),'--','linewidth',2)
%%(b) y'''+4*y'= t, y(0)=y'(0)=0, y''(0)=1
tspan =0:0.01:10;
y0=[0;0;1];
[t,y]= ode45(@ode3, tspan, y0);
figure(3)
plot(t,y(:,1))
% exact solution
ye = @(t) t.^2/8+3/16-(3*cos(2*t))/16;
hold on
plot(t,ye(t),'--','linewidth',2)
%--------------------------------------------------------------------------
function dydt = ode1(t,y)
dydt =[y(2); 2*y(2)-y(1)+exp(t)./(1+t.^2)];
end
function dydt = ode2(t,y)
dydt =[y(2); -2*y(2)-5*y(1)+4*exp(-t)*cos(2*t)];
end
function dydt = ode3(t,y)
dydt =[y(2); y(3); -4*y(2)+t];
endUse the attached journal article - "Chaos in a Three-Species Food Chain" by Hastings
and Powell (Ecology , Jun., 1991) to reproduce FIG. 2 and FIG. 3.
d(x)/(d)t=x(1-x)-f_(1)(x)y
d(y)/(d)t=f_(1)(x)y-f_(2)(y)z-d_(1)y
d(z)/(d)t=f_(2)(y)z-d_(2)z
f_(i)(u)=a_(i)(u)/(1+b_(i)u)Use the attached journal article - "Chaos in a Three-Species Food Chain" by Hastings
and Powell (Ecology , Jun., 1991) to reproduce FIG. 2 and FIG. 3.
dxdt=x(1-x)-f1(x)y
dydt=f1(x)y-f2(y)z-d1y
dzdt=f2(y)z-d2z
fi(u)=aiu1+biu
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions