Numerical Programming I (for CSE)

Similar documents
Numerical Programming I (for CSE)

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

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

Exam in TMA4215 December 7th 2012

5 Numerical Integration & Dierentiation

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

MA2501 Numerical Methods Spring 2015

Bindel, Spring 2012 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 16. f(x) dx,

Preliminary Examination, Numerical Analysis, August 2016

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

Numerical Integration

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

Extrapolation in Numerical Integration. Romberg Integration

Additional exercises with Numerieke Analyse

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

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.

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

Numerical Methods in Physics and Astrophysics

Mathematics for Engineers. Numerical mathematics

Neville s Method. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Neville s Method

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

COURSE Iterative methods for solving linear systems

Numerical Methods. King Saud University

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 Methods in Physics and Astrophysics

(x x 0 )(x x 1 )... (x x n ) (x x 0 ) + y 0.

In numerical analysis quadrature refers to the computation of definite integrals.

Numerical Mathematics

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

Simpson s 1/3 Rule Simpson s 1/3 rule assumes 3 equispaced data/interpolation/integration points

Numerical Methods - Numerical Linear Algebra

Lecture 28 The Main Sources of Error

8.3 Numerical Quadrature, Continued

MA 3021: Numerical Analysis I Numerical Differentiation and Integration

Math Numerical Analysis

Chapter 3 Interpolation and Polynomial Approximation

Numerical techniques to solve equations

Introductory Numerical Analysis

Exercises given in lecture on the day in parantheses.

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

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

BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination December, 2015 BCS-054 : COMPUTER ORIENTED NUMERICAL TECHNIQUES

Lectures 9-10: Polynomial and piecewise polynomial interpolation

INTRODUCTION, FOUNDATIONS

Scientific Computing: Numerical Integration

12.0 Properties of orthogonal polynomials

Computing Integrals. Lectures INF2320 p. 1/48

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

Math Introduction to Numerical Analysis - Class Notes. Fernando Guevara Vasquez. Version Date: January 17, 2012.

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

TABLE OF CONTENTS INTRODUCTION, APPROXIMATION & ERRORS 1. Chapter Introduction to numerical methods 1 Multiple-choice test 7 Problem set 9

Chapter 5: Numerical Integration and Differentiation

Numerical solutions of nonlinear systems of equations

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

Examination paper for TMA4125 Matematikk 4N

5.3 The Power Method Approximation of the Eigenvalue of Largest Module

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)

Numerical Methods for Ordinary Differential Equations

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

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

Integration, differentiation, and root finding. Phys 420/580 Lecture 7

Section 6.6 Gaussian Quadrature

Math 411 Preliminaries

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

MATH 235: Inner Product Spaces, Assignment 7

MAT Linear Algebra Collection of sample exams

Numerical methods. Examples with solution

Applied Numerical Analysis Quiz #2

Math-3315 & CSE-3365, exam 2 answer sheet

Numerical Analysis Comprehensive Exam Questions

Study 4.10 #465, 471, , 487, , , 515, 517, 521, 523

Fall 2014 MAT 375 Numerical Methods. Numerical Differentiation (Chapter 9)

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

6 Lecture 6b: the Euler Maclaurin formula

Chap. 19: Numerical Differentiation

Polynomial Interpolation with n + 1 nodes

On the positivity of linear weights in WENO approximations. Abstract

CAAM 454/554: Stationary Iterative Methods

COURSE Numerical methods for solving linear systems. Practical solving of many problems eventually leads to solving linear systems.

Section 1.1 Algorithms. Key terms: Algorithm definition. Example from Trapezoidal Rule Outline of corresponding algorithm Absolute Error

5. Hand in the entire exam booklet and your computer score sheet.

Numerical methods, midterm test I (2018/19 autumn, group A) Solutions

Chapter 1: Preliminaries and Error Analysis

Virtual University of Pakistan

Numerical Methods I: Numerical Integration/Quadrature

Math 411 Preliminaries

Math 471 (Numerical methods) Chapter 3 (second half). System of equations

3. Numerical Quadrature. Where analytical abilities end...

Introduction to Numerical Analysis

Taylor Series and Numerical Approximations

Numerical Methods. King Saud University

Practice Exam 2 (Solutions)

Differentiation and Integration

Midterm Review. Igor Yanovsky (Math 151A TA)

Integration by Undetermined Coefficients

APPM/MATH Problem Set 6 Solutions

Numerical Algorithms. IE 496 Lecture 20

NUMERICAL METHODS FOR ENGINEERING APPLICATION

Math 227 Sample Final Examination 1. Name (print) Name (sign) Bing ID number

Introduction to Numerical Analysis

Transcription:

Technische Universität München WT / Fakultät für Mathematik Prof. Dr. M. Mehl B. Gatzhammer February 7, Numerical Programming I (for CSE) Repetition ) Floating Point Numbers and Rounding a) Let f : R R be a mapping defined by f(x) 5e x 5. Compute the relative rounding error rd(f(x)) f(x) f(x), where rd(f(x)) takes the rounding errors into account when evaluating f(x). Negation does not produce any rounding errors. Is the computer-based evaluation of f stable? b) Consider the following two Matlab programs: function x function A(p,q) x -p/ + sqrt(p^-4*q)/; end function x function B(p,q) z -p/ - sqrt(p^-4*q)/; x q/z; end Both programs return a solution of the quadratic equation x + px + q. Evaluating the formulas analytically, you would get the same result x in both cases. Evaluating the formulas with Matlab, you get: input output output p q x x*x+p*x+q x x*x+p*x+q.99955978.99955978.99999995.99999995 -.8.999999.99999899999 -.57 4.99999999.999999999.9777 5..9.86576 6..76.7644947 7..99655 -.48484564 8..74558 -.54949476 9. -.. -.. -.. -. In the second column of both outputs, you can see whether the solution x fulfills x +px+q. Assign the outputs and to the programs function A and function B (give reasons for your decision!) and state which program you would choose for solving the equation x + px for some p.

Numerical Programming I (for CSE) Repetition, page a) rd(f(x)) (5(e x ( + ε ))( + ε ) 5)( + ε ). (5e x ( + ε + ε ) 5)( + ε ) (5e x 5)( + ε ) + 5e x (ε + ε )( + ε ). (5e x 5)( + ε ) + 5e x (ε + ε ) f(x)( + ε ) + 5e x (ε + ε ) rd(f(x)) f(x) f(x). [f(x)( + ε ) + 5e x (ε + ε )] f(x) f(x) ( ε + e x e x (ε + ε ) e x ) (ε + ε + ε ) ε e x ε M + e x e x ε M ε M ( + e x ) e x b) with ε i ε M (ε M machine accuracy) not stable! program output A B choose function B lim x (e x ) reason: For p q, we have p/ rd(f(x)) f(x) f(x) x p 4q so that we get cancellation in function A.

Numerical Programming I (for CSE) Repetition, page ) Interpolation Consider the mapping f : R R +, f(x) x6. a) Let p(x) be the polynomial interpolant of f with the support points P (x, y ), P (x, y ), and P (x, y ) and support abscissas x, x, x. Use the scheme of Aitken-Neville to compute p( ). b) Find the coefficients a i (i,,..., 5) of the polynomial interpolant q(x) a + a x + a x + a x + a 4 x 4 that interpolates the mapping f at the support points P i (x i, y i ) (i,,..., 4) with support abscissas x i {,,,, }. Hint: Think first! With a special ansatz, you can reduce the effort for computing q(x) significantly. a) in a triangular scheme (for x ): long version: k : x i i\k y / 9/4 p( ) y 6/ y 64 p, p, + x x (p, p, ) + / x x ( ) p, p, + x x (p, p, ) + / x x (64 ) 6.5 k : p, p, + x x x x (p, p, ) + / ( 6 ) 9 4 7.5 b) We have f(x) f(x) and f(), so we can use the ansatz q(x) a x + a 4 x 4. x : x : a + a 4 f() a + 4 a 4 6 f()

Numerical Programming I (for CSE) Repetition, page 4 solve the linear system ( ) ( ) a 4 a 4 ( ) ( ) a a 4 ) ( a a 4 ( ) 6 ( ) 5 ( ) 4 5 ) Numerical Quadrature Consider the integral where f is a function f : R R. a) Formulate a Matlab program b a f(x)dx, function y simpson sum(f,a,b,n) that computes an approximation of the value of the integral based on the Simpson sum with n subintervals, i.e. with n + function evaluations of f. b) What does the Simpson sum with n 4 subintervals return for f(x) x, a, and b 4? c) Approximating the integral with the trapezoidal sum leads to I : 4 I T 4 in case of n subintervals, I T in case of n 4 subintervals. x dx Compute an extrapolation step to get a better approximation! d) How many partitions (subintervals) n are at least necessary to compute the integral cos(x)dx with the trapezoidal sum with an error of not greater than 75? You may use the estimates sin(x), cos(x). a) function y int simpson(f,a,b,n) h (b-a)/n; xi a:h:b; y feval(f,a) + feval(f,b)... + 4*sum( feval(f,xi(::n)) )... + *sum( feval(f,xi(::n-)) ); y h/ * y; end

Numerical Programming I (for CSE) Repetition, page 5 b) Simpson sum is exact for polynomials of order 4 x dx [ ] 4 x or, alternatively: 4 x dx 4 4 (f() + 4 f() + f() + 4 f() + f(4)) ( + 4 + 8 + 6 + ) 64 c) h, h I(f) T (h ) + T (h ) T (h ) 4 (h + /h ) ( / + ) 64 d) R T S h H f () (ξ) (b a) n (b a) 4 cos(ξ) n! n 75 75 n 5 f () (ξ) 4) Solving Systems of Linear Equations Consider the linear system of equations A x b, A, b (,, ) T. a) Solve the linear system directly, using forward and backward substitution! b) Does the Jacobi method converge when applying it to solve the linear system A x b? a) LU factorization: L L L, A, U A 4 Foward-/backward substitution:...

Numerical Programming I (for CSE) Repetition, page 6 b) iteration matrix C with M D C M (A M) D (D A) eigenvalues of C: λ det(c λi) λ λ ( λ λ ) λ + λ λ( λ )! λ λ, λ, λ ρ(c) < Jacobi method converges since spectral radius of iteration matrix C is <

Numerical Programming I (for CSE) Repetition, page 7 5) Symmetric Eigenvalue Problem Consider the following Matlab code: function eigv qr iteration(a, rtol) nsize(a,); while( code ) 4 A A(:n,:n); 5 while( code ) 6 [Q,R] qr(a(:n, :n)); 7 A code 8 end 9 eigv(n) code 4a n n-; end eigv() code 4b end The function qr iteration returns a vector eigv of length n N that contains the eigenvalues of the n n input matrix A. The input parameter rtol is a positive real value and denotes the relative tolerance ε rtol of the stop criterion a n,n ε rtol a n,n that is used in the QR iteration. What has to stand in the five boxes of the given code so that the Matlab function qr iteration works properly? code : n> code : abs(a(n,n-)) > rtol*abs(a(n,n)) code : R*Q; code 4a : A(n,n); code 4b : A(,);