Additional exercises with Numerieke Analyse

Similar documents
Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University

MA2501 Numerical Methods Spring 2015

Introductory Numerical Analysis

Lecture Note 3: Polynomial Interpolation. Xiaoqun Zhang Shanghai Jiao Tong University

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

Interpolation Theory

In practice one often meets a situation where the function of interest, f(x), is only represented by a discrete set of tabulated points,

Preliminary Examination in Numerical Analysis

Lösning: Tenta Numerical Analysis för D, L. FMN011,

Lecture 10 Polynomial interpolation

Exam in TMA4215 December 7th 2012

Numerical Analysis: Interpolation Part 1

We consider the problem of finding a polynomial that interpolates a given set of values:

SPLINE INTERPOLATION

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

Homework and Computer Problems for Math*2130 (W17).

3.1 Interpolation and the Lagrange Polynomial

Part IB Numerical Analysis

COURSE Numerical integration of functions

Newton's forward interpolation formula

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.

Numerical Methods for Differential Equations

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form

Numerical Programming I (for CSE)

Fourth Order RK-Method

Spring 2012 Introduction to numerical analysis Class notes. Laurent Demanet

Mini project ODE, TANA22

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration.

Chapter 11 ORDINARY DIFFERENTIAL EQUATIONS

Numerical Differential Equations: IVP

Spring 2012 Introduction to numerical analysis Class notes. Laurent Demanet

1. Method 1: bisection. The bisection methods starts from two points a 0 and b 0 such that

Solutions Preliminary Examination in Numerical Analysis January, 2017

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning

Preliminary Examination, Numerical Analysis, August 2016

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

Chapter 1 Numerical approximation of data : interpolation, least squares method

CS 257: Numerical Methods

Applied Math for Engineers

MTH5112 Linear Algebra I MTH5212 Applied Linear Algebra (2017/2018)

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

Examination paper for TMA4125 Matematikk 4N

CHAPTER 4. Interpolation

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

Ordinary Differential Equations

Chapter 5: Numerical Integration and Differentiation

MA3457/CS4033: Numerical Methods for Calculus and Differential Equations

Fixed point iteration and root finding

Lecture Notes on Introduction to Numerical Computation 1

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

Department of Applied Mathematics and Theoretical Physics. AMA 204 Numerical analysis. Exam Winter 2004

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)

Interpolation (Shape Functions)

The problems that follow illustrate the methods covered in class. They are typical of the types of problems that will be on the tests.

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ).

NUMERICAL ANALYSIS I. MARTIN LOTZ School of Mathematics The University of Manchester. May 2016

Ordinary differential equations - Initial value problems

1 Ordinary Differential Equations

Numerical Analysis Preliminary Exam 10.00am 1.00pm, January 19, 2018

Numerical Methods - Initial Value Problems for ODEs

Theory, Solution Techniques and Applications of Singular Boundary Value Problems

Chapter 3 Interpolation and Polynomial Approximation

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method

Numerical Methods for Ordinary Differential Equations

Introduction to the Numerical Solution of IVP for ODE

Some notes on Chapter 8: Polynomial and Piecewise-polynomial Interpolation

AM205: Assignment 3 (due 5 PM, October 20)

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF MATHEMATICS ACADEMIC YEAR / EVEN SEMESTER QUESTION BANK

Curve Fitting and Interpolation

Computational Methods in Civil Engineering

1 Piecewise Cubic Interpolation

Numerical Methods. King Saud University

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

Differentiation. Table of contents Definition Arithmetics Composite and inverse functions... 5

Applied Numerical Analysis (AE2220-I) R. Klees and R.P. Dwight

NUMERICAL ANALYSIS PROBLEMS

November 20, Interpolation, Extrapolation & Polynomial Approximation

Numerical and Statistical Methods

Numerical and Statistical Methods

Numerical Analysis Solution of Algebraic Equation (non-linear equation) 1- Trial and Error. 2- Fixed point

MATH ASSIGNMENT 07 SOLUTIONS. 8.1 Following is census data showing the population of the US between 1900 and 2000:

x n+1 = x n f(x n) f (x n ), n 0.

Computing Integrals. Lectures INF2320 p. 1/48

MA2501 Numerical Methods Spring 2015

Initial Value Problems

Examination paper for TMA4215 Numerical Mathematics

MATHEMATICAL METHODS INTERPOLATION

Chapter 4: Interpolation and Approximation. October 28, 2005

Math Numerical Analysis

Interpolation and Approximation

Numerical Methods for Differential Equations

Fundamentals of Numerical Mathematics. Charles University Prague Faculty of Mathematics and Physics Czech Republic

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

M.SC. PHYSICS - II YEAR

Intro Polynomial Piecewise Cubic Spline Software Summary. Interpolation. Sanzheng Qiao. Department of Computing and Software McMaster University

Interpolation. P. Sam Johnson. January 30, P. Sam Johnson (NITK) Interpolation January 30, / 75

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

Differential Equations

Transcription:

Additional exercises with Numerieke Analyse March 10, 017 1. (a) Given different points x 0, x 1, x [a, b] and scalars y 0, y 1, y, z 1, show that there exists at most one polynomial p P 3 with p(x i ) = y i, i = 0, 1,, p (x 1 ) = z 1. (b) Construct this p in the form p(x) = p (x)+α(x x 0 )(x x 1 )(x x ) with p being the Langange interpolation polynomial of degree corresponding to the set {(x i, y i ) : i = 0, 1, }. (c) Let f be four times differentiable. Show that for the polynomial p P 3 with p(x i ) = f(x i ), i = 0, 1,, p (x 1 ) = f (x 1 ) and any x [a, b], there exists a ξ = ξ(x) (a, b) with f(x) p(x) = (x x 0 )(x x 1 ) (x x ) f (4) (ξ). 4!. (a) Find weights w 0, w 0, w 1, w 1 such that b a for any f P 3. f(x)dx = w 0 f(a) + w 0 f (a) + w 1 f(b) + w 1 f (b) (b) Show that for f C 4, the error in this quadrature formula, i.e., true integral minus its approximation, is of the form C(b a) 5 f (4) (ξ) for some ξ [a, b], and give the constant C. (c) Splitting the interval into m equal subintervals, give the resulting composite quadrature formula. (d) Show that the error in this composite formula is equal to C (b a)5 f (4) (ξ) m 4 for some ξ [a, b]. 3. For a < b, {x 0,..., x n } R, show that there are unique weights w 0,..., w n such that n i=0 w if(x i ) = b f(x)dx for all f P a n. 1

4. (Runge phenomenon). Let f(x) = 1/(1 + x ). (a) For n = 1, 4, 8, 1 make plots on [ 5, 5] of the Lagrange interpolation polynomial p n with interpolation points x (n) k = 5 + 10k/n, k = 0,..., n, and of f p n. Use e.g. the MATLAB functions polyfit, poly and polyval. Where is the interpolation error large? (b) For n as above, approximate max x [ 5,5] f(x) p n (x) by evaluating this absolute error on say 150 equally distributed points. What do you notice? (c) Repeat the previous questions for the Chebychev roots x (n) 5 cos( (k+ 1 )π ), k = 0,..., n and compare the results. n+1 k = (d) Compare max x [ 5,5] (x x (n) 0 )... (x x (n) n ) for both sets of interpolation points and draw a conclusion. Hand in: For n = 8 and both choices of the interpolation points the values of max x [ 5,5] (x x (n) 0 )... (x x (n) n ) and plots of f p n, and the m-files you used to generate these results. 5. (Adaptive quadrature) Given a function f, let T [c,d] (m) be the result of the approximation of d f(x)dx by means of the composite trapezium c rule on m equal subintervals. Assuming that f is sufficiently smooth, we know that d c f(x)dx T [c,d] (m) = 1 (d c) [f (d) f (c)] + O(m 4 ) 1 m (a) Approximate the integral of x 3 over [a, b] = [ 1, 100] by the composite trapezium rule T [a,b] (m) for m = k. Find the smallest k, 10 such that the exact error is less than ε = 10 3. Explain the slow convergence. To improve the convergence rate of the above problem we may use an adaptive strategy: instead of dividing an interval into m equal subintervals, we can try to recursively subdivide only those subintervals where the trapezium rule makes a large error. For this we need to estimate the error of the trapezium rule on a given interval.

(b) Verify that the error estimate d c f(x)dx T [c,d] (m) T [c,d](m) T [c,d] (m) 3 is exact when the O(m 4 ) and O((m) 4 ) terms can be ignored. The right hand side is computable, and thus can be used for an estimate. An adaptive strategy now is: Compute T [a,b] (), and accept it as an approximation when the estimated error is less or equal to a desired tolerance ε. Otherwise, apply the procedure to b+a b b+a f(x)dx with tolerances ε/. a f(x)dx and (c) Write a recursive MATLAB function that implements the adaptive strategy. (d) Apply the adaptive routine to the function x 3 with a, b, ε as before. What is the exact error in the obtained approximation? How do the number of function evaluations that are required compare to that with the strategy used in (a)? Hand in m-files that you have used in (5a) and (5c), and the answers to the questions posed in (5d). 6. Let a < b, m N, h := b a m, x i := a + ih for i {0,..., m}, and for n {1,,...}, let S n := {s C n 1 (a, b) : s (xi 1,x i ) P n (1 i m)}. Furthermore, let I 1 : C[a, b]) S 1 the continuous piecewise linear interpolator, and let I 3 : C 1 [a, b]) S 3 the complete cubic spline interpolator defined by s(x i ) = f(x i ) (i {0,..., m}), (1) s (x 0 ) = f (x 0 ), s (x m ) = f (x m ). () where s is here a shorthand notation for I 3 (f). The aim of this exercise is to show that f I 3 (f) = O(h 4 ) when f is sufficiently smooth. From formula (11.5) from the book, we know that each s S 3 can be written as s [xi 1,x i ](x) = (x i x) 3 6h σ i 1 + (x x i 1) 3 σ i + α i (x x i 1 ) + β i (x i x), 6h 3

for some scalars α 1,..., α m, β 1,..., β m and, for i {0,..., m}, with σ i = s (x i ). By imposing (1) we obtain α i = f(x i) h h 6 σ i, β i = f(x i 1) h h 6 σ i 1. (a) By using the continuity of s in x 1,..., x m 1 and (), show that A[σ 0... σ m ] = b, where A R (m+1) (m+1) is defined by 4 1 4 1 A =..., 1 4 1 4 and b R m+1 by b i = 1 [ f (x m) h 1 [ f(x 1 ) f(x 0 ) f (x 0 )] h h 6 f(x i+1) f(x i )+f(x i 1 ) when i = 0, ] h when i {1,..., m 1}, f(xm) f(x m 1) h when i = m. Elementary linear algebra shows that A is invertible, and that A 1 1, i.e., that max i (A 1 x) i 1 max i x i (Indeed, writing A = 4(I (I 1 4 A)) and using that I 1 4 A = 1, shows that A 1 1 ), (b) Show that I 3 (f) 3 f. (Hint: Show that s = max 0 i m σ i and that max 0 i m b i 6 f.) (c) Show that I 3 is a projector, i.e., that I 3 (s) = s for any s S 3. (d) Show that for any p S 1 there exists a s S 3 with s = p. (e) Let s S 3 be such that s = I 1 (f ). Show that f I 3 (f) = f s I 3 (f s), and with that, show that f I 3 (f) 4 f s 1 h f (4). 4

n=0 n=1 n= n=3 n=4 0 h h 3h 4h 5h Figure 1: The functions S (n,0) for n = 0,..., 4. (f) Show that I 1 (f I 3 (f)) = 0, and with that show that as well as for some constant C > 0. f I 3 (f) 1 16 h4 f (4), f I 3 (f) Ch 3 f (4) 7. Let a < b, m N, n N 0 := N {0}, h := b a m and S n := {s C n 1 (a, b) : s (a+(i 1)h,a+ih) P n (1 i m)}, being the spline space of degree n w.r.t. the subdivision of [a, b] in m equal subintervals (and with C 1 (a, b) being the space of bounded functions on [a, b]). For convenience, we take a = 0. With n+1 ( ) n + 1 S (n) (x) := ( 1) k (x kh) n k +, k=0 we define S (n,l) (x) := S (n) (x lh) for l Z. (a) Show that S (n,l) [0,b] S n. (b) Show that supp S (n,l) [lh, (l + n + 1)h]. (c) Show that dim S n = m + n = #{l Z : S (n,l) [0,b] 0}. (d) Show that S (n+1,l) (x) = (n+1)(s (n,l)(x) S (n,l+1) (x)) (when n = 0 only for x hz). (e) From Exercise 11.6, we know that S (n+1,l) (x) = (x lh)s (n,l) (x) + ((n + + l)h x)s (n,l+1) (x). 5

Using induction to n, from this show that S (n,l) (x) = h n n!. l Z Now we are going to show that for all p Z, c l S (n,l) (ph,(p+1)h) = 0 = c l = 0 for p n 1 < l < p + 1. (3) l Z (f) Show that (3) holds for n = 0. (g) Now let (3) be valid for some n N 0. Let l Z c ls (n+1,l) and so l Z c ls (n+1,l) vanish on (ph, (p + 1)h). Using (7d), show that this implies that for some constant c R, c l = c for all p n < l < p + 1, and with that c l S (n+1,l) (ph,(p+1)h) = c S (n+1,l) (ph,(p+1)h) = ch n+1 (n + 1)! l Z l Z Conclude that (3) is valid for n + 1, and so for any n N 0. (h) Using (7a), (7c), and (3), show that { S(n,l) [0,b] : l { n,..., m 1} } is a basis for S n. 8. Consider the initial value problem(ivp): { y (x) = f(x, y(x)) 0 x 1 y(0) = 0 where f(x, y) = (1 + x)(1 + y ). (a) Verify that the exact solution is given by y(x) = tan(x + x /). A possible implementation of the Forward Euler method (FE) for solving this IVP is given below. 6

function Euler(N) % N is the number of the time steps f=@(x,y)(1+x)*(1+y.^); % defines the function f y=@(x) tan(x+x.^/); % defines exact solution h=1/n; % time step x=0:h:1; xfine=0:0.01:1 FE=zeros(1,N+1); % Forward Euler approximation solution err=zeros(1,n+1); % Error values of Forward Euler method FE(1)=0; for i=1:n FE(i+1)=FE(i)+h*f(x(i),FE(i)); end for i=1:n+1 err(i)=y(x(i))-fe(i); end plot(xfine,y(xfine)); hold on; plot(x,fe); (b) Run Forward Euler with h 1 = N = 10, 0, 40, 80, 160 and compare the errors. (c) To compare the error of FE with other numerical methods, solve the problem with the modified Euler method: { yi+1 = y i + 1 (k 1 + k ) where k 1 = hf(x i, y i ), k = hf(x i + h, y i + k 1 ) and the following Runge-Kutta scheme: y i+1 = y i + h(k 6 1 + k + k 3 + k 4 ) where k 1 = f(x i, y i ), k = f(x i + h, y i + h k 1 ), k 3 = f(x i + h, y i + h k ), k 4 = f(x i + h, y i + hk 3 ) (d) Plot the error in the point 1 vs. N for the three methods, and estimate the order of the methods. To do this, it is most convenient to use a log-log plot. 9. To illustrate the numerical solution of a so-called stiff ODE, consider the IVP { y (x) = λ(sin(x) y) + cos(x) 0 x 1, λ 1 y(0) = 0 7

with exact solution y(x) = sin(x). (a) Apply the FE method to this problem with λ = 00 and h 1 = N = 10, 90, 100, 105, 1000. (b) Implement the Backward Euler method (BE): y i+1 = y i + hf(x i+1, y i+1 ) and run it with the same values of h and λ. Compare the results. (c) With x i = ih, define the truncation error of the Backward Euler method by T (BE) i = y(x i+1) y(x i ) f(x i+1, y(x i+1 )) h and show that T (BE) i = h y (ξ) for some ξ [x i, x i+1 ]. Similarly, let T (FE) i = y(x i+1) y(x i ) f(x h i, y(x i )), which is known to be of the form h y (η) for some η [x i, x i+1 ]. (d) With e i := y(x i ) y e i and e (BE) i i+1 = (1 hλ)e i + ht e (BE) i+1 = e(be) i + ht (BE) i 1 + hλ := y(x i ) y (BE) i, show that. i, Show that for 1 i h 1, e (BE) i 1 h y, and, when h 1, 100 e i 1 h y. Explain the behaviour of the error of FE when N < 100. Is there a contradiction with the result of Theorem 1. applied to FE? 10. For x 0 < x 1 < < x n, where n, and k N, consider the spline space S (k) = {s C k 1 (x 0, x n ) : s (xi,x i+1 ) P k, i = 0,..., n}. (a) Show that the only s S (1) with s(x 0 ) = s(x n ) = 0 and such that for any i 0, j, i + j n, s (xi,x i+j ) has j 1 zeros, is the zero function. (Hint: Show that if s 0, then there exists i and j as above with s(x i ) = 0 and s(x i+j ) = 0 and s(x i+1 ) 0,..., s(x i+j 1 ) 0, and derive a contradiction.) 8

(b) Show that the only p P 3 (a, b) with p(a) = p(b) = 0 and p 0 is the zero polynomial. (c) Show that there exists at most one natural cubic spline interpolant, i.e., an t S (3) with t (x 0 ) = t (x n ) = 0 that for some given y 0,..., y n satisfies t(x i ) = y i (0 i n). (Hint: suppose two, and consider the difference.) 11. Archimedes (50 v. Chr.) obtained upper and lower bounds for π by measuring the perimeter of regular inscribed or circumscribed polygons for a circle with radius 1. In this exercise we consider inscribed polygons only. (a) Let T 0 (h) be the perimeter of regular inscribed polygon with n sides, where nh = 1. Show that T 0 (h) = h 1 sin(πh). (b) Show that there exist constants (c i ) such that m N π T 0 (h) = m c i h i + O(h m+ ) (h 0). i=1 (c) Determine α 1, β 1 such that T 1 (h/) := α 1 T 0 (h/) + β 1 T 0 (h) satisfies π T 1 (h/) = O(h 4 ) (h 0). Huygens used this idea already in 1654. Archimes measurements went to n = 96. Assuming that Huygens used these measurements, which we assume to be exact, what were the errors in the best approximations that they both obtained? (d) Improve Huygens, i.e., determine α, β such that T (h/4) := α T 1 (h/4) + β T 1 (h/) satisfies π T (h/4) = O(h 6 ) (h 0). What is the error in T (1/96)? 9

Figure : The inscribed regular polygons for h = 1/8 and h = 1/16. 1. To approximate a (a > 0) we apply the Newton scheme to f(x) = x a = 0. (a) Verify that this yields the following iteration: x i+1 = 1 (x i + a x i ). (b) Show that for any x 0 > a, the sequence (x i ) i 0 is monotone decreasing. (c) Show that for any 0 < x 0 < a, the sequence (x i ) i 1 is monotone decreasing. Now we consider the Newton iteration with x 0 = 1 (1 + a). (d) Show that x 0 is the result of one step of Newton iteration starting with x 1 = 1, and thus that x 0 > a. (e) Show that if for some i 0, x i x i+1 < ɛ, that then x i+1 a < ɛ, which provides a useful stopping criterion. 13. Skipped 10