numerical integration · • romberg’s method. numerical integration the numerical methods used...

27
Numerical Integration

Upload: others

Post on 17-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

Page 2: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Content

• Numerical Integration• Method of Undetermined Coefficients• Newton-Cotes Quadrature• Romberg’s Method

Page 3: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

The numerical methods used to solve the Defined Integration of a function are:

• Method of Undetermined Coefficients• Newton-Cotes Quadrature• Romberg’s Method

Page 4: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

The Definite Integral is expressed as

𝐼𝐼 = �𝑎𝑎

𝑏𝑏𝑓𝑓 𝑥𝑥 𝑑𝑑𝑥𝑥

where 𝒇𝒇(𝒙𝒙) is a continuous function at the interval (a, b), and this represents the area under the curve 𝒚𝒚 = 𝒇𝒇(𝒙𝒙) between 𝒙𝒙 = 𝒂𝒂 and 𝒙𝒙 = 𝒃𝒃.If the interval (𝒂𝒂,𝒃𝒃) is divided in 𝑵𝑵 subintervals (𝒙𝒙𝒊𝒊,𝒙𝒙𝒊𝒊+𝟏𝟏) of length 𝒉𝒉 (𝒉𝒉 = ∆𝒙𝒙), one obtains a set of rectangles of width 𝒉𝒉 and height 𝒇𝒇(𝒙𝒙𝒊𝒊) and the area of each is 𝒇𝒇(𝒙𝒙𝒊𝒊)𝒉𝒉.

Page 5: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

• The area under the curve can be approximated by the sum of the areas of these rectangles, so that we can obtain the definite integral as follows

• Therefore, an approximation method of 𝑰𝑰 would calculating the sum of the areas

• where 𝒏𝒏 is a very large but finite integer.

Page 6: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

• Intuitively, a better approximation of the integral number may be defined to calculate the sum of the trapezoidal areas, where the area of the trapezoid 𝒊𝒊 would be

• The sum 𝑻𝑻 of these trapezoidal areas is then

Page 7: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration

• Examining the above formula we can see that any of these two numerical methods of approximation of an defined integral can be written form of the sum of the weights of the ordinates

• where 𝑨𝑨𝒊𝒊 are suitable constants (weights), and 𝒇𝒇(𝒙𝒙𝒊𝒊) are suitably chosen ordinates of the function.

• The error between the definite integral and these approximations we can obtain the following relationship

Page 8: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

• In this section, we will determine a set of constants 𝑨𝑨𝒊𝒊 such that the error 𝑬𝑬 defined in the relationship

• is zero for arbitrary distinct 𝒙𝒙𝒊𝒊 when 𝒇𝒇(𝒙𝒙) is any polynomial 𝒑𝒑𝒏𝒏(𝒙𝒙) of degree no exceeding 𝒏𝒏.

Page 9: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

• Now, if the error 𝑬𝑬 is zero when 𝒇𝒇(𝒙𝒙) is any polynomial of degree not exceeding 𝒏𝒏, then it must be zero when 𝒇𝒇 𝒙𝒙 = 𝟏𝟏,𝒙𝒙,𝒙𝒙𝟐𝟐, … ,𝒙𝒙𝒏𝒏.

• by substituting successively 𝟏𝟏,𝒙𝒙,𝒙𝒙𝟐𝟐, … ,𝒙𝒙𝒏𝒏 to 𝒇𝒇(𝒙𝒙) in the error equation, we obtain the following system of equations where are linear in the unknown constants 𝑨𝑨𝒊𝒊 (imposing the constraint that 𝑬𝑬 =𝟎𝟎 in each case )

Page 10: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

For 𝑓𝑓 𝑥𝑥 = 1, ∫𝑎𝑎𝑏𝑏 1𝑑𝑑𝑥𝑥 = 𝐴𝐴01 + 𝐴𝐴11 + ⋯+ 𝐴𝐴𝑛𝑛1

For 𝑓𝑓 𝑥𝑥 = 𝑥𝑥, ∫𝑎𝑎𝑏𝑏 𝑥𝑥𝑑𝑑𝑥𝑥 = 𝐴𝐴0𝑥𝑥0 + 𝐴𝐴1𝑥𝑥1 + ⋯+ 𝐴𝐴𝑛𝑛𝑥𝑥𝑛𝑛

For 𝑓𝑓 𝑥𝑥 = 𝑥𝑥2, ∫𝑎𝑎𝑏𝑏 𝑥𝑥2𝑑𝑑𝑥𝑥 = 𝐴𝐴0𝑥𝑥02 + 𝐴𝐴1𝑥𝑥12 + ⋯+ 𝐴𝐴𝑛𝑛𝑥𝑥𝑛𝑛2

For 𝑓𝑓 𝑥𝑥 = 𝑥𝑥𝑛𝑛, ∫𝑎𝑎𝑏𝑏 𝑥𝑥𝑛𝑛𝑑𝑑𝑥𝑥 = 𝐴𝐴0𝑥𝑥0𝑛𝑛 + 𝐴𝐴1𝑥𝑥1𝑛𝑛 + ⋯+ 𝐴𝐴𝑛𝑛𝑥𝑥𝑛𝑛𝑛𝑛

Page 11: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

• Writing the above equations in matrix form, we obtain

• Solving this system of equations we obtain the values of 𝑨𝑨𝒊𝒊 which can apply to the following formula for the approximation of the definite integral

Page 12: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

Example• Finding the Integral of cosh(𝑥𝑥) from 0 to 2.

• Considering the points 𝑥𝑥 = 0, 𝑥𝑥 = 1 and 𝑥𝑥 = 2 and 𝑓𝑓(𝑥𝑥) = cosh(𝑥𝑥)

Page 13: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

Page 14: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Method of Undetermined Coefficients

• The exact solution of the example is:

• Then the total error is:Error = |3.62686 − 3.644839| = 0.017979

Page 15: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients
Page 16: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Newton-Cotes Quadrature

• The well-known Trapezoid Rule, Simpson’s 1/3 Rule and Newton’s 3/8 Rulebelong to the Newton-Cotes (closed) class of numerical integration (quadrature) methods for approximating

𝑰𝑰 ≡ �𝒂𝒂

𝒃𝒃𝒇𝒇 𝒙𝒙 𝒅𝒅𝒙𝒙

• These quadrature formulas are denoted by 𝑸𝑸𝒏𝒏𝒏𝒏 and are of the general form

where 𝒇𝒇∗(𝒙𝒙) is a polynomial interpolation.

Page 17: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Newton-Cotes Quadrature

Features:1. For equally spaced values of 𝒙𝒙, that is 𝒙𝒙𝒊𝒊+𝟏𝟏 − 𝒙𝒙𝒊𝒊 = 𝒉𝒉2. 𝒇𝒇(𝒙𝒙) is approximated by a Newton’s Forward interpolating polynomial, 𝑷𝑷𝒌𝒌(𝒙𝒙) where:

𝒌𝒌 ≤ 𝒏𝒏, for odd 𝒏𝒏𝒌𝒌 ≤ 𝒏𝒏 + 𝟏𝟏, for even 𝒏𝒏

3. N subintervals groups are taken to calculate 𝑷𝑷𝒌𝒌(𝒙𝒙) in each group

Page 18: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Newton-Cotes Quadrature

• Trapezoid Rule 𝑸𝑸𝟏𝟏𝟏𝟏

• Simpson’s 1/3 Rule 𝑸𝑸𝟐𝟐𝟐𝟐

• Newton’s 3/8 Rule 𝑸𝑸𝟑𝟑𝟑𝟑

Page 19: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients
Page 20: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients
Page 21: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Romberg’s Method

Computationally more efficient, more accurately. The method consists of two steps:a) Calculate approximations

�𝒂𝒂

𝒃𝒃𝒇𝒇 𝒙𝒙 𝒅𝒅𝒙𝒙

using 𝑄𝑄11(Trapezoid Rule), for different values 𝒉𝒉𝒌𝒌; where

𝒉𝒉𝒌𝒌 =(𝒃𝒃 − 𝒂𝒂)𝟐𝟐𝒌𝒌

; 𝒌𝒌 = 𝟎𝟎, …

called 𝑻𝑻𝟎𝟎𝒌𝒌

Page 22: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Romberg’s Method

b) Apply the recursion formula of Romberg on 𝑻𝑻𝟎𝟎𝒌𝒌 approximations found in a), to find the 𝑻𝑻𝟏𝟏𝒌𝒌 approximations. The formula is applied to the extent possible.

𝑻𝑻𝒎𝒎𝒌𝒌 =𝟒𝟒𝒎𝒎𝑻𝑻𝒎𝒎−𝟏𝟏

𝒌𝒌+𝟏𝟏 − 𝑻𝑻𝒎𝒎−𝟏𝟏𝒌𝒌

𝟒𝟒𝒎𝒎 − 𝟏𝟏

Page 23: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients
Page 24: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Homework 9 (Individual)

1. Use the method of undetermined coefficients to approximate

using 𝑥𝑥0 = 0.0, 𝑥𝑥1 = 0.5, 𝑥𝑥2 = 1.0.2. Approximate

Using: a) Trapezoidal Rule with ℎ = 0.125; b) Simpson’s 1/3 rule with ℎ = 0.125; c) Rule Newton’s 3/8 with ℎ = 2/12.

Page 25: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Homework 9 (Individual)

3. Approximate the following function by Romberg method with h = 1, 0.5, 0.25, 0.125, until h ≤ d = 0.125.

Consider for this case 9 digits of accuracy.

Page 26: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Computer Program 8 (by team)

• Submit a computer program that calculates the Numerical Integration of the above problems for each corresponding method.

• Hand over:• Computational algorithm (printed)• Source Code (printed and file)• Executable (file)

Page 27: Numerical Integration · • Romberg’s Method. Numerical Integration The numerical methods used to solve the Defined Integration of a function are: • Method of Undetermined Coefficients

Numerical Integration