Get started today!

Good to have you back!
If you've signed in to StudyBlue with Facebook in the past, please do that again.

- StudyBlue
- Arizona
- Arizona State University - Tempe
- Mathematics
- Mathematics 275
- Roudenko
- LAB07 [Part 2].pdf

Anonymous

74 MATLAB sessions: Laboratory 7 0 5 10 15 20 25 30 35 40−1.5 −1 −0.5 0 0.5 1 1.5 y(t) v(t)=y’(t) −1 −0.8−0.6−0.4−0.2 0 0.2 0.4 0.6 0.8 1−1.5 −1 −0.5 0 0.5 1 1.5 y v=y’ Figure L7a: Time series y = y(t) and v = v(t) = y0(t) (left), and phase plot v = y0 vs. y for (L7.1). (b) What seems to be the long term behavior of y? (c) Modify the initial conditions and run the flle LAB07ex1.m with the modifled initial conditions. Does the long term behavior of the solution change? Explain why or why not. 2. Modify the flle LAB07ex1.m to solve the IVP y00 + 2y0 + y = cost with y(0) = y0(0) = 0. Plot both time series of y and y0 and the phase plot y0 vs y. Describe the behavior of the solution y (in particular in the long term). Additional Considerations Using euler.m The routine euler.m used in LAB1 can be used without modiflcation to flnd an approximate solution for (L7.1): function LAB07ex2 % driver for Figure L7b t0 = 0; tf = 40; % initial and final times y0 = -1; v0 = 0; % initial conditions % ode45 solution [t,Y] = ode45(@f,[t0,tf],[y0,v0]); y = Y(:,1); v = Y(:,2); % Euler solution h = 0.1; N = round((tf-t0)/h); [te,Ye] = euler(@f,[t0,tf],[y0,v0],N); ye = Ye(:,1); ve = Ye(:,2); figure(1); plot(t,y,’b.-’,te,ye,’r.-’); % time series for y and v ylim([-1.5,1.5]) legend(’ode45’,’Euler’); grid on figure(2); plot(y,v,’b.-’,ye,ve,’r.-’,’Linewidth’,2); % phase plot xlabel(’y’); ylabel(’v=y’’’); grid on axis([-1,1,-1.5,1.5]) legend(’ode45’,’Euler’); grid on %------------------------------------ function dYdt = f(t,Y) y = Y(1); v = Y(2); dYdt = [ v ; cos(t)-4*v-3*y ]; MATLAB sessions: Laboratory 7 75 For comparison the solution y obtained with ode45 is included in the plot, see Figure L7b. 0 5 10 15 20 25 30 35 40 45−1.5 −1 −0.5 0 0.5 1 1.5 ode45 Euler −1 −0.8−0.6−0.4−0.2 0 0.2 0.4 0.6 0.8 1−1.5 −1 −0.5 0 0.5 1 1.5 y v=y’ ode45 Euler Figure L7b: Time series y = y(t) (left) and phase plane v = y0 vs. y (right) obtained from ode45.m and euler.m for the problem (L7.1). 3. Modify the flle LAB07ex2.m in order to solve the problem (L7.1) using the improved Euler method from Laboratory 2. Compare the results with those obtained from ode45 and euler by plotting pictures similar to L7b but including the Improved Euler approximation as well. Nonlinear Problems Nonlinear problems do not present any additional di–culty from an implementation point of view (they may present new numerical challenges for integration routines like ode45). As an example consider the modifled problem d2y dt2 +4y 2dy dt +3y = cost; with y(0) = ¡1; dy dt(0) = 0: (L7.4) The ODE (L7.4) is very similar to (L7.1) except for the y2 term in the left-hand side. Because of the factor y2 the ODE (L7.4) is nonlinear, while (L7.1) is linear. There is however very little to change in the implementation of (L7.1) to solve (L7.4). The driver part in LAB07ex1 is not modifled (same initial conditions) while the ODE deflnition becomes function dYdt = f(t,Y) y = Y(1); v = Y(2); dYdt = [ v ; cos(t)-4*y^2*v-3*y ]; The new output is shown in Fig L7c. 4. (a) Compare the output of Figs L7a and L7c. Describe the changes in the behavior of the solution in the short term. (b) Increase the time interval of computation. Compare the long time behavior of both problems (L7.1) and (L7.4), in particular the amplitude of oscillations. 5. Solve numerically the IVP d2y dt2 +4jyj dy dt +3y = cost; with y(0) = ¡1; dy dt(0) = 0 in the interval 0 • t • 40. Is the behavior of the solution signiflcantly difierent from that of the solution of (L7.4)? Comment. In particular, compare the size of the long term oscillations in y with that of the problems (L7.1) and (L7.4).

Advertisement
)

Advertisement

"StudyBlue is great for studying. I love the study guides, flashcards and quizzes. So extremely helpful for all of my classes!"

Alice , Arizona State University"I'm a student using StudyBlue, and I can 100% say that it helps me so much. Study materials for almost every subject in school are available in StudyBlue. It is so helpful for my education!"

Tim , University of Florida"StudyBlue provides way more features than other studying apps, and thus allows me to learn very quickly!??I actually feel much more comfortable taking my exams after I study with this app. It's amazing!"

Jennifer , Rutgers University"I love flashcards but carrying around physical flashcards is cumbersome and simply outdated. StudyBlue is exactly what I was looking for!"

Justin , LSU