Solution Manual for: Numerical Computing with MATLAB by Cleve B. Moler

Similar documents
Ordinary Differential Equations I

Ordinary Differential Equations I

APPM 2360: Midterm exam 1 February 15, 2017

Ordinary Differential Equations I

The Plan. Initial value problems (ivps) for ordinary differential equations (odes) Review of basic methods You are here: Hamiltonian systems

Chapter 6 - Ordinary Differential Equations

Math 322. Spring 2015 Review Problems for Midterm 2

Ordinary Differential Equations

Section 7.4 Runge-Kutta Methods

The family of Runge Kutta methods with two intermediate evaluations is defined by

Higher-order differential equations

Nonhomogeneous Equations and Variation of Parameters

Numerical Methods for the Solution of Differential Equations

Math 23: Differential Equations (Winter 2017) Midterm Exam Solutions

Answer Key b c d e. 14. b c d e. 15. a b c e. 16. a b c e. 17. a b c d. 18. a b c e. 19. a b d e. 20. a b c e. 21. a c d e. 22.

1. Diagonalize the matrix A if possible, that is, find an invertible matrix P and a diagonal

The Fundamental Theorem of Calculus: Suppose f continuous on [a, b]. 1.) If G(x) = x. f(t)dt = F (b) F (a) where F is any antiderivative

Lecture 1. Scott Pauls 1 3/28/07. Dartmouth College. Math 23, Spring Scott Pauls. Administrivia. Today s material.

MIDTERM 1 PRACTICE PROBLEM SOLUTIONS

Math K (24564) - Homework Solutions 02

Math 215/255 Final Exam (Dec 2005)

SECTION 3.3. PROBLEM 22. The null space of a matrix A is: N(A) = {X : AX = 0}. Here are the calculations of AX for X = a,b,c,d, and e. =

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

MathQuest: Differential Equations

. For each initial condition y(0) = y 0, there exists a. unique solution. In fact, given any point (x, y), there is a unique curve through this point,

Solutions to Homework 5 - Math 3410

Math 341 Fall 2008 Friday December 12

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Solution: In standard form (i.e. y + P (t)y = Q(t)) we have y t y = cos(t)

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

APPM 2360 Section Exam 3 Wednesday November 19, 7:00pm 8:30pm, 2014

Solutions to Homework 3

Differential equations

1 Differential Equations

Second Order Linear Equations

Solutions to Math 53 Math 53 Practice Final

Homework Solutions: , plus Substitutions

Math 323 Exam 2 Sample Problems Solution Guide October 31, 2013

Old Math 330 Exams. David M. McClendon. Department of Mathematics Ferris State University

y0 = F (t0)+c implies C = y0 F (t0) Integral = area between curve and x-axis (where I.e., f(t)dt = F (b) F (a) wheref is any antiderivative 2.

Part IB Numerical Analysis

First Order Linear Ordinary Differential Equations

Section 2.4 Linear Equations

Entrance Exam, Differential Equations April, (Solve exactly 6 out of the 8 problems) y + 2y + y cos(x 2 y) = 0, y(0) = 2, y (0) = 4.

Numerical Methods - Initial Value Problems for ODEs

University of Alberta ENGM 541: Modeling and Simulation of Engineering Systems Laboratory #5

APPM 2360: Midterm exam 3 April 19, 2017

Section 9.8 Higher Order Linear Equations

MATH 307: Problem Set #3 Solutions

Simple ODE Solvers - Derivation

Chapter 5 Exercises. (a) Determine the best possible Lipschitz constant for this function over 2 u <. u (t) = log(u(t)), u(0) = 2.

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

Ordinary differential equations - Initial value problems

Linear algebra and differential equations (Math 54): Lecture 20

1 Systems of Differential Equations

Chap. 20: Initial-Value Problems

A: Brief Review of Ordinary Differential Equations

Numerical solution of ODEs

Richarson Extrapolation for Runge-Kutta Methods

Ordinary Differential Equations. Monday, October 10, 11

ACCELERATION OF RUNGE-KUTTA INTEGRATION SCHEMES

Sect2.1. Any linear equation:

Homogeneous Equations with Constant Coefficients

SOLVING DIFFERENTIAL EQUATIONS. Amir Asif. Department of Computer Science and Engineering York University, Toronto, ON M3J1P3

Physics 584 Computational Methods

Chapter 1: Introduction

8.1 Introduction. Consider the initial value problem (IVP):

Numerical Integration of Ordinary Differential Equations for Initial Value Problems

Ordinary Differential Equations II

First-Order ODEs. Chapter Separable Equations. We consider in this chapter differential equations of the form dy (1.1)

FINAL EXAM SOLUTIONS, MATH 123

Ordinary differential equation II

FINAL EXAM MATH303 Theory of Ordinary Differential Equations. Spring dx dt = x + 3y dy dt = x y.

3.5 Undetermined Coefficients

Ordinary Differential Equations

Exam 2 Solutions. (a) Is W closed under addition? Why or why not? W is not closed under addition. For example,

MA 527 first midterm review problems Hopefully final version as of October 2nd

UC Berkeley Math 10B, Spring 2015: Midterm 2 Prof. Sturmfels, April 9, SOLUTIONS

Lecture 2. Classification of Differential Equations and Method of Integrating Factors

The integrating factor method (Sect. 1.1)

Final Exam Sample Problems, Math 246, Spring 2018

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers

Systems of Linear ODEs

ODE Homework 1. Due Wed. 19 August 2009; At the beginning of the class

Ordinary Differential Equations: Initial Value problems (IVP)

Ordinary Differential Equations II

Initial value problems for ordinary differential equations

Reduction to the associated homogeneous system via a particular solution

CS520: numerical ODEs (Ch.2)

8. Qualitative analysis of autonomous equations on the line/population dynamics models, phase line, and stability of equilibrium points (corresponds

Section 3: Summary. Section 4. Evaluating Convolution Integrals. Convolution integral (memorise this):

This is a closed book exam. No notes or calculators are permitted. We will drop your lowest scoring question for you.

Higher Order Taylor Methods

1.2. Direction Fields: Graphical Representation of the ODE and its Solution Let us consider a first order differential equation of the form dy

40h + 15c = c = h

Higher Order Linear Equations

Introduction to numerical simulations for Stochastic ODEs

ODEs Cathal Ormond 1

Solutions to the Review Questions

DETERMINANTS DEFINED BY ROW OPERATIONS

Transcription:

Solution Manual for: Numerical Computing with MATLAB by Cleve B. Moler John L. Weatherwax July 5, 007 Chapter 7 (Ordinary Differential Equations) Problem 7.1 Defining the vector y as y Then we have for its time derivative the following v dt u v ü v u v u y y 1 (1) y 3 y 4 + cos(r) 1+t sin(r) 1+t () Where r given in terms of components of y is r y4 + y 3 (3) Given the initial conditions in terms of u, v, u, and v we have 0 y 0 1 0 (4) 0 wax@alum.mit.edu 1

Problem 7. See the matlab code in the file prob 7.m. Problem 7.3 The algorithm BS3 can be represented by the following sequence of steps s 1 f(t n, y n ) (5) s f(t n + h, y n + h s 1) (6) s 3 f(t n + 3 4 h, y n + 3 4 s ) (7) y n+1 y n + h 9 (s 1 + 3s + 4s 3 ) (8) Part (a): The specific ODE s (and their exact solutions) to consider are given by dt dt dt dt 1 y t + C (9) t y t + C (10) t y t3 3 + C (11) t 3 y t4 4 + C (1) For the first system, /dt 1, so f(t, y) 1 then the BS3 procedure gives the following s 1 1 (13) s 1 (14) s 3 1 (15) y n+1 y n + h 9 ( + 3 + 4) y n + h (16) Does this equal the true solution at t n + h? We evaluate the above to obtain y(t n + h) (t n + h) + C t n + C + h y n + h (17) and the answer is yes. For the second function f(t, y) t we see that the BS3 procedure is s 1 t n (18) s t n + h (19) s 3 t n + 3 4 h (0) y n+1 y n + h (t n + 3(t n + h ) + 4(t n + 3 h)) (1) 4

Simplifying this last equation we have y n + h 9 (9t n + ( 3 + 3)h) () y n + ht n + h 9 (9 )h (3) y n + ht n + h Again we ask, does this equal the true solution at t n+1? Lets check by evaluating (4) y(t n+1 ) y(t n + h) 1 (t n + h) + C t n + C + ht n + h y(t n) + ht n + h and we see that the answer is yes. For the second function f(t, y) t, then the BS3 gives (5) s 1 t n (6) s (t n + h ) (7) s 3 (t n + 3 4 h) (8) y n+1 y n + h 9 (t n + 3(t n + h ) + 4(t n + 3 4 h) ) (9) Now simplifying the last equation we have y n+1 y n + h 9 (t n + (3 + 6)ht n + ( 3 4 + 9 4 )h ) (30) y n + h 9 (9t n + 9 ht n + 1 4 h ) (31) y n + ht n + h t n + h 3 1 3 Does this equal the exact solution at t n + h? To decide we compute (3) y(t n + h) (t n + h) 3 + C 1 3 3 (t3 n + 3t n h + 3t nh + h 3 ) + C (33) t3 n 3 + C + (t n h + t nh + h3 3 ) (34) and we see that the answer is yes. Finally, for the function f(t, y) t 3, the BS3 algorithm gives s 1 t 3 n (35) s (t n + h )3 t 3 n + 3 t n h + 3 4 t nh + 1 8 h3 (36) s 3 (t n + 3 4 h)3 t 3 n + 9 4 t n h + 7 16 t nh + 7 64 h3 (37) y n+1 y n + h 9 (t3 n + 3(t3 n + 3 t n h + 3 4 t nh + 1 8 h3 ) (38) +4(t 3 n + 9 4 t n h + 7 16 t nh + 7 64 h3 )) (39)

Simplifying this last term gives y n+1 y n + ht 3 n + 3 t n h + t n h 3 + h4 6 The true solution at t n + h however is equal to (40) y(t n + h) (t n + h) 4 + C 1 4 4 (t4 n + 4t3 n h + 6t n h + 4t n h 3 + h 4 ) + C (41) 1 4 t4 n + C + t 3 nh + 3 t nh + t n h 3 + h4 4 (4) y n + ht 3 n + 3 t nh + t n h 3 + h4 4. (43) Since this differs from the the approximate solution by ( 1 6 1 4) h 4 we see that this method is not exact for f(t) t 3. Part (b): The BS3 error estimate is given by e n+1 h 7 ( 5s 1 + 6s + 8s 3 9s 4 ) (44) where s i for i 1,, 3, 4 is computed as above. When one computes s 1, s, s 3, and s 4 for f(t) 1 and f(t) t one obtains a zero estimation error. Considering the function f(t) t we have an estimated error given by e n+1 h 7 ( 5t n + 6(t n + h ) + 8(t n + 3 4 h) 9(t n + h) ) (45) when one expands the above expression one obtains e n+1 h3 4 which is not zero. Thus the estimated error is exact for f(t) 1 and f(t) t only. (46) Problem 7.4 See the matlab code in the file prob 7 4.m. Problem 7.5 Part (a): See the matlab code in the file myrk4.m. Part (b): The local truncation error of RK4 is given by O(h 4+1 ), so the global truncation error should be O(h 4 ). When you decrease the step size h by this should reduce the global error by 1/ 4 1/16. An experiment illustrating this behaviour can be found in

the routine/code prob 7 5.m. There we sequentially decrease the stepsize parameter h and compute the global error between the final timestep and the known true solution value. We then plot the log of stepsize parameter v.s. the log of the global error. On this plot one can see that in this space we have a linear decrease in error representing a powerlaw. A linear function is fitted to to this data with the Matlab function polyfit. The slope of this line is given by 4 empirically displaying the known relation between the error and the stepsize of error h 4 Part (c): For this problem formulation our differential equation is given by ÿ y. The system formulation for this equation is given by defining [ ] [ ] y1 (t) y(t) Y (47) y (t) ẏ(t) then d dt Y (t) d [ y(t) dt ẏ(t) ] [ ẏ(t) ÿ(t) ] so in total in terms of y 1 and y the differential equation is [ ] [ ] d y1 y dt y y 1 [ y (t) y 1 (t) ] (48) (49) This is implemented in the Matlab code prob 7 5 fn.m. In addition, in the driver routine prob 7 5.m we have implemented the numerical experiments mentioned in the book and have verified the statements there. Problem 7.6 Part (a): The differential equation ẏ 1000y + 1000 sin(t) + cos(t) with y(0) 1 (50) has a homogeneous solution given by y(t) Ce 1000t and a particular solution given by a function of the form A sin(t)+b cos(t). By putting this particular solution into the equation above we can solve for the coefficients A and B. When we do this we get the following A cos(t) B sin(t) 1000A sin(t) 1000B cos(t) + 1000 sin(t) + cos(t) (51) Grouping the coefficients of cos(t) and sin(t) we obtain (A + 1000B 1) cos(t) + ( B + 1000A 1000) sin(t) 0. (5) When we require that the coefficients of cos(t) and sin(t) vanish we obtain the following system of equations A + 1000B 1 0 (53) B + 1000A 1000 0. (54)

The solution to the first equation in terms of B is given by A 1 1000B. When substituted into the second equation we obtain 1000(1 1000B) B 1000 (55) Which has as its solution B 0. Thus A 1 giving in total the solution y of y(t) sin(t) + Ce 1000t (56) using the initial condition y(0) 1 we obtain C 1 and the total analytical solution is given by y(t) e 1000t + sin(t) (57) I should mention that heuristically this problem is midly stiff because of the various time scales present in the solution. The exponential term has a timescale O(1/1000) while the sin term has a timescale like O(1) or effectivly three orders of magnitude different. Part (b)-(f): See the routines prob 7 6.m and prob 7 6 fn.m for an implementation of this problem. Problem 7.7 Part (a): Each equation has as its solution y(t) sin(t). Part (b): The corresponding first order system for the third given differential equations is (defining y 1 (t) y(t)) [ ] [ ] [ ] [ ] d y1 y 0 1 y1 (58) dt y y 1 1 0 y The corresponding system for the fourth differential equation is given by [ ] [ ] [ ] [ ] [ ] d y1 y 0 1 y1 0 + dt y sin(t) 0 0 y sin(t) Note that the first representation above is autonomous while the second is not. Part (c): The Jacobian for each of the functions f involved in the definitions of each differential equation are given by f 1 y f y f 3 y f 4 y 0 y 1 y [ ] 0 1 1 0 [ ] 0 1 0 0 From the above we can see that as t π that WWX finish (59)

Problem 7.9 Consider the matrix A given by A 0 η 0 σ σ η ρ 1 (60) Expanding the determinant of the above matrix we have or or A σ σ ρ 1 η 0 η σ σ (61) A (σ σρ) η(ση) (6) A η ρ + (63) Setting this equal to zero to find the values where the matrix is singular we see that η ± (ρ 1). (64) Which was the expression we were looking to find. To find the vectors in the nullity of A when η is one of these special values, insert this into the matrix above and reduce it to row-echelon form. Inserting this expression into A means we are looking for a vector v such that Av 0 ± (ρ 1) 0 σ σ (ρ 1) ρ 1 v 1 v v 3 0 (65) dividing the first row in the above expression by and the second row by σ we obtain (ρ 1) 1 0 v 1 0 1 1 v 0 (66) (ρ 1) ρ 1 v 3 Now multiplying the first row by ± (ρ 1) and adding it to the third row we obtain (ρ 1) 1 0 0 1 1 0 ρ 1 (ρ 1) (ρ 1) v 1 v v 3 0 (67) which simplifies to (ρ 1) 1 0 0 1 1 0 ρ ρ v 1 v v 3 0. (68)

which demonstrates that the third row is indeed a multiple of the second row. Eliminating this row we obtain the following requirements among the coefficients of v (ρ 1) v 1 ± v 3 (69) v v 3 (70) Letting v 3 η (ρ 1) and assuming that ρ 1 > 0 we see that the above null vector has components given by as desired. v 1 ρ 1 (71) v η (7) v 3 η (73) Problem 7.10 (the Jacobian of the Lorenz equations) The Lorenz equations are given by ẏ Ay, with y 1 (t) y(t) y (t) and A y 3 (t) 0 y (t) 0 σ σ y (t) ρ 1 Performing the matrix multiplication we have for the full non-linear system representing the Lorenz equations, the following y 1 y 1 (t) + y (t)y 3 (t) y σy (t) + σy 3 (t) y 3 y 1 (t)y (t) + ρy (t) y 3 (t). This expression makes it easier to compute the required Jacobian of our mapping f( ). We find that y 3 (t) y (t) J 0 σ σ. y (t) y 1 (t) + ρ 1 The fixed points of the Lorentz equations are given by solving for y in f(y) 0, which gives the following system of equations y 1 + y y 3 0 σy + σy 3 0 y 1 y + ρy y 3 0. The second equation above has the simple solution of y y 3, which when used in the first and third equaions above gives y 1 + y 0 y 1 y + ρy y 1 0.,

The last equation above can be factored as y ( y 1 + ρ 1) 0, which has as solutions y 0, and y 1 ρ 1. Following the consequences of each of these choices, if y 0, then y 1 0, while if y 1 ρ 1 then the first equation above gives (ρ 1) + y 0, which has a solution given by y ± (ρ 1). Thus in summary then the three fixed points of the Jacobian of the Lorentz equations are (y 1, y, y 3 ) (0, 0, 0) (y 1, y, y 3 ) (ρ 1, (ρ 1), (ρ 1)) (y 1, y, y 3 ) (0, 0, 0).