Question: EXERCISES ( a ) Consider the modified problem ( d ^ ( 2 ) y ) / ( dt ^ ( 2 ) ) +

EXERCISES
(a) Consider the modified problem
(d^(2)y)/(dt^(2))+8y^(2)(dy)/(dt)+7y=8sint, with ,y(0)=-1,(dy)/(dt)(0)=0
The ODE (7) is very similar to (4) except for the y^(2) term in the left-hand side. Because of the
factor y^(2) the ODE (7) is nonlinear, while (4) is linear. There is however very little to change
in the implementation of (4) to solve (7). In fact, the only thing that needs to be modified is
the ODE definition.
Modify the function defining the ODE in LABO4ex1.m. Call the revised file LABO4ex2.m. The
new function M-file should reproduce the pictures in Fig 8.
Include in your report the changes you made to LABO4ex1.m to obtain LABO4ex2.m.
Figure 8: Time series y=y(t) and v=v(t)=y^(')(t)(left), and phase plot v=y^(') vs. y for (7).
(b) Compare the output of Figs 7 and 8. Describe the changes in the behavior of the solution in
the short term.
(c) Compare the long term behavior of both problems (4) and (7), in particular the amplitude of
oscillations.
(d) Modify LAB04ex2.m so that it solves (7) using Euler's method with N=600 in the interval
0=t=50(use the file euler.m from LAB 3 to implement Euler's method; do not delete the
lines that implement ode45). Let [te, Ye] be the output of euler, and note that Ye is a ma-
trix with two columns from which the Euler's approximation to y(t) must be extracted. Plot
the approximation to the solution y(t)v(t) nor the phase
plotN ?
ex_with_2eqs.m
t0=0; tf =20; y0=[10;60];
a =.8; b =.01; c =.6; d =.1;
[t,y]= ode45(@f,[t0,tf],y0,[],a,b,c,d);
u1= y(:,1); u2= y(:,2); % y in output has 2 columns corresponding to u1 and u2
figure(1);
subplot(2,1,1); plot(t,u1,'b-+'); ylabel('u1');
subplot(2,1,2); plot(t,u2,'ro-'); ylabel('u2');
figure(2)
plot(u1,u2); axis square; xlabel('u_1'); ylabel('u_2'); % plot the phase plot
%----------------------------------------------------------------------
function dydt = f(t,y,a,b,c,d)
u1= y(1); u2= y(2);
dydt =[ a*u1-b*u1*u2 ; -c*u2+d*u1*u2];
end
ex_with_param
function ex_with_param
t0=0; tf =3; y0=1;
a =1;
[t,y]= ode45(@f,[t0,tf],y0,[],a);
disp(['y(' num2str(t(end))')=' num2str(y(end))])
disp(['length of y =' num2str(length(y))])
end
%-------------------------------------------------
function dydt = f(t,y,a)
dydt =-a*(y-exp(-t))-exp(-t);
end
EXERCISES ( a ) Consider the modified problem ( d

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!