Numerical Differentiation and Integration

Introduction

Let us consider a set of values (π‘₯𝑖, 𝑦𝑖) of a function. The process of computing the derivative or
derivatives of that function at some values of x from the given set of values is called Numerical
Differentiation. This may be done by first approximating the function by suitable interpolation
formula and then differentiating.

Derivatives using Newton’s Forward Difference formula

Newton’s forward interpolation formula

Derivate using Newton’s Backward Difference Formula

Newton’s backward interpolation formula is

At π‘₯ = π‘₯𝑛, 𝑝 = 0, hence putting p=0 in equation 10 we get

Note: first derive is also as rate of change, so it can also be asked to find the velocity, second
derivate to find acceleration.

Example: find the first, second and third derivate of 𝑓(π‘₯)π‘Žπ‘‘ π‘₯ = 1.5 if

π‘₯1.52.02.53.03.54.0  
𝑓(π‘₯)3.3757.013.6252438.87559.0  

Solution
We have to find the derivate at the points π‘₯ = 1.5, which is at the beginning of the given data.
Therefore, we use the derivate of Newton’s Forward Interpolation formula.
Forward difference table is

ere π‘₯0 = 1.5, 𝑦0 = 3.375, βˆ†π‘¦0 = 3.625, βˆ† 2𝑦0 = 3, βˆ† 3𝑦0 = 0.75, βˆ† 4𝑦0 = 0, β„Ž = 0.5

Now using equation for finding the derivate

Example:
The population of a certain town (as obtained from central data) is shown in the following table

Year19511961197119811991  
population (thousand)19.3636.6558.8177.2194.61

Find the rate of growth of the population in the year 1981

Solution
Here we have to find the derivate at 1981 which is near the end of the table, hence we use the
derivative of Newtons Backward difference formula. The table if difference is as follows:

Here β„Ž = 10, π‘₯𝑛 = 1991, βˆ‡π‘¦π‘› = 17.4, βˆ‡ 2𝑦𝑛 = βˆ’1, βˆ‡ 3𝑦𝑛 = 2.76, βˆ‡ 4𝑦𝑛= 11.99

We know derivate for backward difference is

Maxima and minima of tabulated function

We know Newton’s forward interpolation formula as :

We know that maximum and minimum values of a function 𝑦 = 𝑓(π‘₯) can be found by equating 𝑑𝑦/𝑑π‘₯ to zero and solution for x

Now for keeping only up to third difference we have

Solving this for p, by substituting βˆ†π‘¦0, βˆ† 2𝑦0, βˆ† 3𝑦0, we get π‘₯ as π‘₯0 + π‘β„Ž at which y is a maximum or minimum

Example: given the following data, find the maximum value of y

π‘₯-1123
𝑦-2115123  

Since the arguments (x -points) aren’t equally spaced we use Newton’s Divided Difference formula

𝑦(π‘₯) = π‘Ž0 + π‘Ž1 (π‘₯ βˆ’ π‘₯0 ) + π‘Ž2 (π‘₯ βˆ’ π‘₯0 )(π‘₯ βˆ’ π‘₯1 ) + π‘Ž3 (π‘₯ βˆ’ π‘₯0 )(π‘₯ βˆ’ π‘₯1 )(π‘₯ βˆ’ π‘₯2 )…

From above table π‘Ž0 = βˆ’21, π‘Ž1 = 18, π‘Ž2 = βˆ’7, π‘Ž3 = 1,

𝑓(π‘₯) = βˆ’21 + 18(π‘₯ + 1) + (π‘₯ + 1)(π‘₯ βˆ’ 1)(βˆ’7) + (π‘₯ + 1)(π‘₯βˆ’1)(π‘₯ βˆ’ 2)(1) 𝑓(π‘₯) = π‘₯ 3 βˆ’ 9π‘₯ 2 + 17π‘₯ + 6

For maxima and minima 𝑑𝑦/𝑑π‘₯ = 0

3π‘₯ 2 βˆ’ 18π‘₯ + 17 = 0

On solving we get
π‘₯ = 4. .8257 π‘œπ‘Ÿ 1.1743
Since x=4.8257 is out of range [-1 to 3] , we take x=1.1743

∴ π‘¦π‘šπ‘Žπ‘₯ = π‘₯ 3 βˆ’ 9π‘₯ 2 + 17π‘₯ + 6

= 1.17433 βˆ’ 9 βˆ— 1.17342 + 17 βˆ— 1.1743 + 6

= 15.171612

Differentiating continuous function

If the process of approximating the derivative 𝑓′(π‘₯) of the function f(x), when the function itself is
available

Forward Difference Quotient
Consider a small increment βˆ†π‘₯ = β„Ž in x, according to Taylor’s theorem, we have

Equation 3 is called first order forward difference quotient. This is also known as two-point formula.
The truncation error is in the order of h and can be decreased by decreasing h.
Similarly, we can show that the first order backward difference quotient is

Central Difference Quotient

This equation is called second order difference quotient. Note that this is the average of the forward
difference quotient and backward difference equation. This is also called as three-point formula.

Example: estimate approximate derivative of 𝑓(π‘₯) = π‘₯ 2 π‘Žπ‘‘ π‘₯ = 1, for h=0.2,0.1,0.05 and 0.01, using first order forward difference formula

We know that

Derivative approximation is tabulated below as:

Note that the correct answer is 2. The derivative approximation approaches the exact value as h
decreases.
Now for central difference quotient

Numerical Integration

Newtons Cotes Formula

This is the most popular and widely used in numerical integration.
Numerical integration method uses an interpolating polynomial 𝑝𝑛(π‘₯) in place of f(x)

Above equation is known as Newton’s Cote’s quadrature formula, used for numerical integration
If the limits of integration a and b are in the set of interpolating points xi=0,1,2,3…..n, then the formula
is referred as closed form. If the points a and b lie beyond the set of interpolating points, then the
formula is termed as open form. Since the open form formula is not used for definite integration, we
consider here only the closed form methods. They include:

  1. Trapezoidal rule
  2. Simpson’s 1/3 rule
  3. Simpson’s 3/8 rule
Trapezoidal rule (2 point formula)

Putting n=1 in equation 1 and neglecting second and higher order differences we get

Composite Trapezoidal Rule

If the range to be integrated is large, the trapezoidal rule can be improved by dividing the interval
(a,b) into a number of small intervals. The sum
of areas of all the sub-intervals is the integral of
the intervals (a,b) or (x0,xn). this is known as
composite trapezoidal rule.

As seen in the figure, there are n+1 equally spaced sampling point that create n segments of equal width h given by

π‘₯𝑖 = π‘Ž + π‘–β„Ž 𝑖 = 0,1,2, … n

From the equation of trapezoidal rule,

The total area of all the n segments is

Above equation is known as composite trapezoidal rule

Simpson’s 1 ⁄ 3 rule( 3 point formula)

Another popular method is Simpson’s 1/3 rule. Here the function f(x) is approximated by second
order polynomial 𝑝2(π‘₯) which passes through three sampling points as shown in figure. The three
points include the end point a & b and midpoint between π‘₯1 = (π‘Ž + 𝑏)/2. The width of the segment
h is given by β„Ž = (𝑏 βˆ’ π‘Ž)/𝑛 . Take n=2 and neglecting the third and higher order differences we get
(in newton’s cote formula)

Simpson’s 3/8 rule( 4 point rule)

Example:

Solution
Taking h=1, divide the whole range of the integration [0,10] into ten equal parts. The value of the integrand for each point of sub division

Romberg integration formula/ Richardson’s deferred approach to the limit or Romberg
method

Take an arbitrary value of h and calculate

Gaussian integration

Gaussian integration is based on the concept that the accuracy of numerical integration can be improved by choosing sampling points wisely rather than on the basis of equal sampling. The problem is to compute the values of π‘₯1& π‘₯2 given the value of a and b and to choose approximate weights w1 & w2 . The method of implementing the strategy of finding approximate values of xi & wi and obtaining the integral of f(x) is called Gaussian integration or quadrature. Gaussian integration assumes an approximation of the form

The above equation 1 contains 2n unknowns to be determined. For example for n=2, we need to find the values of w1,w2,x1,x2. We assume that the integral will be exact up to cubic polynomial. This implies the function x1,x2&x3 can be numerically integrated to obtain exact results.

Assume f(x)=1 (assume the integral is exact up to cubic polynomial)

This formula will give correct value for the integral of f(x) in the range (-1,1) for any function
up to third order. The above equation is called gauss Legrendre formula

Changing limits of Integration

Note that the Gaussian formula imposed a restriction on the limits of integration to be from -1 to 1.
The restriction can be overcome by using the techniques of the β€œinterval transformation” used in
calculus, let

Assume the following transformation between x and new variable z. by following relation.
i.e x=Az+B
this must satisfy the following conditions at x=a, z=-1 & x=b, z=1
i.e B-A=a, A+B=b

Where wi and zi are the weights and quadrature points for the integration domain (-1,1)

Values for gaussian quadrature

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

Leave a Comment