Exercises, module A (ODEs, numerical integration etc)

Similar documents
Integration of Ordinary Differential Equations

EXAMPLE OF ONE-STEP METHOD

Fourth Order RK-Method

x x2 2 + x3 3 x4 3. Use the divided-difference method to find a polynomial of least degree that fits the values shown: (b)

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

Second Order ODEs. CSCC51H- Numerical Approx, Int and ODEs p.130/177

Chapter 8. Numerical Solution of Ordinary Differential Equations. Module No. 1. Runge-Kutta Methods

JUST THE MATHS UNIT NUMBER DIFFERENTIATION APPLICATIONS 5 (Maclaurin s and Taylor s series) A.J.Hobson

Consistency and Convergence

Chapter 11 ORDINARY DIFFERENTIAL EQUATIONS

ODE Runge-Kutta methods

THE TRAPEZOIDAL QUADRATURE RULE

11.10a Taylor and Maclaurin Series

Degree Master of Science in Mathematical Modelling and Scientific Computing Mathematical Methods I Thursday, 12th January 2012, 9:30 a.m.- 11:30 a.m.

Do not turn over until you are told to do so by the Invigilator.

Examples of solutions to the examination in Computational Physics (FYTN03), October 24, 2016

Logistic Map, Euler & Runge-Kutta Method and Lotka-Volterra Equations

Differential Equations

Checking the Radioactive Decay Euler Algorithm

Chapter 11. Taylor Series. Josef Leydold Mathematical Methods WS 2018/19 11 Taylor Series 1 / 27

Homework #3 Solutions

Solving Differential Equations Using Power Series

Solving Differential Equations Using Power Series

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

Math 225 Differential Equations Notes Chapter 1

Math 113 (Calculus 2) Exam 4

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

Solutions to Assignment-11

SYSTEMS OF ODES. mg sin ( (x)) dx 2 =

Module Two: Differential Calculus(continued) synopsis of results and problems (student copy)

LECTURE 14: REGULAR SINGULAR POINTS, EULER EQUATIONS

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 20

Bernoulli Polynomials

i x i y i

Numerical Solution of Differential Equations

Initial Value Problems

Multiplicative Runge-Kutta Methods

Series Solutions of Differential Equations

Numerical Analysis Preliminary Exam 10 am to 1 pm, August 20, 2018

Taylor Series. richard/math230 These notes are taken from Calculus Vol I, by Tom M. Apostol,

FINITE DIFFERENCES. Lecture 1: (a) Operators (b) Forward Differences and their calculations. (c) Backward Differences and their calculations.

Chap. 19: Numerical Differentiation

The Definition and Numerical Method of Final Value Problem and Arbitrary Value Problem Shixiong Wang 1*, Jianhua He 1, Chen Wang 2, Xitong Li 1

Completion Date: Monday February 11, 2008

Chap. 20: Initial-Value Problems

Series Solution of Linear Ordinary Differential Equations

Numerical Methods. King Saud University

Applied Math for Engineers

Mini project ODE, TANA22

Principles of Scientific Computing Local Analysis

MTH4101 CALCULUS II REVISION NOTES. 1. COMPLEX NUMBERS (Thomas Appendix 7 + lecture notes) ax 2 + bx + c = 0. x = b ± b 2 4ac 2a. i = 1.

Review: Power series define functions. Functions define power series. Taylor series of a function. Taylor polynomials of a function.

Euler s Method, cont d

Regression and Nonlinear Axes

Engg. Math. I. Unit-I. Differential Calculus

Chapter 4 Sequences and Series

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations

4.4 Computing π, ln 2 and e

= D ( )( ) derivative

Higher order derivatives of the inverse function

OR MSc Maths Revision Course

Taylor series - Solutions

Lecture V: The game-engine loop & Time Integration

Explicit One-Step Methods

Taylor and Maclaurin Series

Equations with regular-singular points (Sect. 5.5).

AP Calculus Testbank (Chapter 9) (Mr. Surowski)

Physics 115/242 Romberg Integration

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

Study Guide/Practice Exam 3

Extrapolation in Numerical Integration. Romberg Integration

Do not turn over until you are told to do so by the Invigilator.

Multiple Choice Review Problems

Solutions: Problem Set 3 Math 201B, Winter 2007

3 Applications of partial differentiation

Chapter 1. Numerical Errors. Module No. 3. Operators in Numerical Analysis

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

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

Lecture 4: Extended Kalman filter and Statistically Linearized Filter

Study # 1 11, 15, 19

Lecture Notes on. Differential Equations. Emre Sermutlu

ECONOMICS 207 SPRING 2006 LABORATORY EXERCISE 5 KEY. 8 = 10(5x 2) = 9(3x + 8), x 50x 20 = 27x x = 92 x = 4. 8x 2 22x + 15 = 0 (2x 3)(4x 5) = 0

CALCULUS JIA-MING (FRANK) LIOU

MA 162 FINAL EXAM PRACTICE PROBLEMS Spring Find the angle between the vectors v = 2i + 2j + k and w = 2i + 2j k. C.

Math Real Analysis II

Polytechnic Institute of NYU MA 2132 Final Practice Answers Fall 2012

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

Virtual University of Pakistan

Math Exam 2, October 14, 2008

Section Taylor and Maclaurin Series

Computational Methods CMSC/AMSC/MAPL 460. Ordinary differential equations

Problem Sheet 0: Numerical integration and Euler s method. If you find any typos/errors in this problem sheet please

Some Applications of the Euler-Maclaurin Summation Formula

Math 104: l Hospital s rule, Differential Equations and Integration

Computation Fluid Dynamics

MATLAB Laboratory 10/14/10 Lecture. Taylor Polynomials

Notation Nodes are data points at which functional values are available or at which you wish to compute functional values At the nodes fx i

MTH603 FAQ + Short Questions Answers.

Preliminary Examination in Numerical Analysis

Transcription:

FYTN HT18 Dept. of Astronomy and Theoretical Physics Lund University, Sweden Exercises, module A (ODEs, numerical integration etc) 1. Use Euler s method to solve y (x) = y(x), y() = 1. (a) Determine y after n steps of size h, y n. What is the exact solution? (b) For which values of h is the sequence y,y 1,... bounded? (c) Let y(x,h) denote the estimate of y(x) obtained for step size h. Determine the global error y(x,h) y(x) to leading order in h, for fixed x.. Solve the initial value problem y (x) = xy(x), y() = 1. What is the analytic solution? Use the nd order Runge-Kutta with a = b = 1/ and m = 1 and step size h =.. Compare the results from the Runge-Kutta method with the exact result at time t = h. What is the relative error? Compare also to the relative error obtained using the Euler method.. Use the Euler-Maclaurin summation formula to show that n m = 1 n(n+1) and n m = 1 6 n(n+1)(n+1) 4. Calculate 4 dx x with the trapezoidal rule for the step sizes.5,.5 och.15. Improve the values by Richardson extrapolation. 5. Calculate the integral in exercise 4 by using two-point Gaussian integration, after a change of variable to t = x 7. 6. Determine an integration formula of the type f(x)(1+x )dx A 1 f(x 1 )+A f(x ) that is exact for all polynomials with degree less than 4. 7. Consider the boundary value problem y (x) y(x) = with y() = and y(1) = sinh(1). What is theanalytic solution? Solve this problemusingthe matrix methodwith a step size h =.5 (this gives -equation system to be diagonalized). Compare your numerical solution to the analytic result.

Solutions 1. Use Euler s method to solve y (x) = y(x), y() = 1. (a) Determine y after n steps of size h, y n. What is the exact solution? Solution: Theanalytic solution is y(x) = e x - we look for afunction whosederivative is proportional to itself, this is clearly an exponential function. If we would rather want to derive this result, note that the equation above can be written y (x)/y(x) =, or equivalently dln[y(x)]/dx =. Integrating from to x on both sides give ln[y(x)] = x, or, y(x) = e x. Let us now turn to the Euler algorithm. Discretizing x via x n = nh with a step-size h and defining y n = y(x n ), the Euler algorithm becomes: y = 1 y 1 y(+h) = 1 h y y(+h) = (1 h) y n y(+nh) = (1 h) n (b) For which values of h is the sequence y,y 1,... bounded? Solution: A bounded sequence is one for which, for all n [, ], y n remains finite. So for our case, where y n = (1 h) n, we must require h. (c) Let y(x,h) denote the estimate of y(x) obtained for step size h. Determine the global error y(x,h) y(x) to leading order in h, for fixed x. Solution: Using the fact that n = x/h, we write y n = y(x,h) = (1 h) x/h. Note that we have y(x,h) = exp[lny(x,h)] = exp[(x/h)ln(1 h)], so that using the Taylor expansion of the logarithm ln[1+z] z z /, we have y(x,h) exp[ x(1+h/)] exp( x) = y(x,h = ) = y(x) when h as it should. We now proceed by Taylor expanding the the approximate solution, y(x, h), for small h according to y(x,h) = y(x,h = )+h dy(x,h) h= +... dh Using the fact that (use the Taylor expansion of the logarithm to second order and 1/(1+z) 1 z for small z below) ( dy(x, h) = (1 h) x/h x dh h(1 h) + xln(1 h) ) h xe x / as h and that y(x,h = ) = y(x) we find y(x,h) y(x) h xe x /+O(h ) i.e. the global error scales linearly with h as it should for the Euler algorithm. Note that we here, besides the correct scaling with h, also calculated an explicit expression for the prefactor in the global error estimate.

. Solve the initial value problem y (x) = xy(x), y() = 1. What is the analytic solution? Use the nd order Runge-Kutta with a = b = 1/ and m = 1 and step size h =.. Compare the results from the Runge-Kutta method with the exact result at time t = h. What is the relative error? Compare also to the relative error obtained using the Euler method. Solution: We write y (x) = f(x,y(x)) with f(x,y(x)) = xy(x). The analytic solution is y(x) = exp( x /). as can be derived using the integrating factor method, for instance. The nd order Runge-Kutta method is k 1 = hf(x n,y n ) k = hf(x n +mh,y n +mk 1 ) y n+1 = y n +ak 1 +bk where y n = y(x n ) and x n = nh. The first iteration gives: k 1 = hx y =. 1 = k = h(x +mh)(y +mk 1 ) = (.) =.4 y 1 = y +ak 1 +bk =.98 with a = b = 1/ and m = 1. The second iteration is: k 1 = hx 1 y 1 =...98 =.9 k = h(x 1 +mh)(y 1 +mk 1 ) =..4 (.98.9).75 y = y 1 +ak 1 +bk.9 Comparing this to the exact expression we find a relative error 4 1 4. If we instead use the Euler method, which for the present problem becomes: y n+1 = y n hx n y n = (1 hx n )y n, we find: y 1 = (1 hx )y = 1 y = (1 hx 1 )y 1 = (1..) 1 =.96 this gives a relative error 4 1 compared to the analytic solution.. Use the Euler-Maclaurin summation formula to show that n m = 1 n(n+1) and n m = 1 6 n(n+1)(n+1) Solution: Using h = 1 in the Euler-Maclaurin formula gives us f() + n f(m)+ f(n) n = f(m)dm+ c k k=1 with c k = B k (k)! (f(k) (n) f (k) ())

and where B i are the Bernoulli numbers (B = 1, B = 1/6, B 4 = /,...). So in the first sum, we use f(m) = m. The integral gives n / and we need to add f(n)/ = n/. The first derivative of f is constant and all higher derivatives are zero so all c k vanish and the result is n(n+1)/. In the second sum we use f(m) = m. The integral becomes n / and we add f(n)/ = n /. The derivative of f is m and the B = 1/6 so we need to add c 1 = 1/6! (n ), all other c k vanish. The result is n(n+1)(n+1)/6. 4. Calculate the integral 4 dx I = x with the trapezoidal rule for the step sizes.5,.5 och.15. Improve the values by Richardson extrapolation. Solution: The exact answer is ln() ln(1) = ln().69. Discretizing x between the integration limits as x = x n (n =,1,...,N) where x = and x N = 4 and defining f n = f(x n ) the trapezoidal method is: Thus, ( f1 I trapz (h) h +f +f +...+ f ) N. ( f() I trapz (.5) =.5 ( f() I trapz (.5) =.5 +f(.5)+ f(4) ).78, +f(.5)+f(.5)+f(.75)+ f(4) ).697. ( f() I trapz (.15) =.15 +f(.15)+f(.5)+f(.75)+f(.5)+f(.65) +f(.75)+f(.875) + f(4) ).6941. The relative errors compared to the exact result are. and.56 respectively. Using one Richardson extrapolation step we get the improved estimates of the integral I: and Î(.5) = 4I trapz(.5) I trapz (.5).695 Î(.15) = 4I trapz(.15) I trapz (.5).6915 Two Richardson extrapolation steps yields: ˆÎ = 16Î(.15) Î(.5) 15.6915 with a relative error 1 6, i.e. a result very close to the exact one. 5. Calculate the integral in exercise 4 by using two-point Gaussian integration, after a change of variable to t = x 7. Solution: After the suggested change of variables the integral becomes I = dt t+

i.e. on the form given in ODE lectures 4 and 5. Using the explicit formula derived there: 1 I 1/+ + 1 1/+ giving a relative error of.1 compared to the exact result. 6. Determine an integration formula of the type f(x)(1+x )dx A 1 f(x 1 )+A f(x ) that is exact for all polynomials with degree less than 4. Solution: We need the corresponding second order orthogonal polynomial, and we use the Gram-Schmidt method with w(x) = 1+x. As always φ = 1. φ 1 = x φ x φ φ φ = x φ = x φ 1 x φ 1 φ 1 φ 1 φ x φ φ φ = x 5 So the zeros are ± /5. Inserting f(x) = 1 gives (x +1)dx = 8 = A 1 +A and f(x) = x gives So A 1 = A = 4/ and x(x +1)dx = = A 1 ( /5)+A ( /5) f(x)(1+x )dx 4 f( /5)+ 4 f( /5) is exact for all polynomials with degree less than 4. 7. Consider the boundary value problem y (x) y(x) = with y() = and y(1) = sinh(1). What is theanalytic solution? Solve this problemusingthe matrix methodwith a step size h =.5 (this gives -equation system to be diagonalized). Compare your numerical solution to the analytic result. Solution: The analytic solution is: y(x) = sinh(x) Discretizing y (x) y(x) = gives y n+1 (+h )y n +y n for n = 1,,. The boundary condition becomes: y = and y 4 = sinh(1). Or, on matrix form, A y = b, we have (+h ) 1 A = 1 (+h ) 1 1 (+h ) and b = sinh(1) Comparing the solution of this equation system to the exact result we find that the relative errors for x n =.5,.5 and.75 are roughly 7.6 1 4, 6. 1 4 and.4 1 4 respectively.