CH6 Numerical Differentation

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 52

Numerical Methods:

Numerical
Differentiation
Introduction
Numerical differentiation is a mathematical method
used to approximate the derivative of a function
using numerical calculations instead of analytical
methods. The derivative of a function at a point
is the slope of the tangent line to the function at
that point. In many cases, the function to be
differentiated cannot be expressed analytically or
is too complicated to differentiate analytically. In
such cases, numerical differentiation can be a
useful tool for estimating the derivative.
Table of contents

01 02
Analytical Purpose and
Differentiation importance

03 04
Comparison of
Methods
Methods
Analytical
01 Differentiatio
n
Analytical
Differentiation
Analytical differentiation refers to the process of
finding the exact derivative of a function
using algebraic rules and formulas.
It involves taking the limit of the difference
quotient as the change in the independent
variable approaches zero.
Analytical differentiation is typically used to
find the derivative of simple functions with
closed-form expressions.
Analytical Differentiation

Limitations:
Example:
Consider the derivative of sin(x) + e^x using Analytical differentiation is limited to functions that have
Analytical Differentiation with x=1. closed-form expressions or can be easily expressed in terms
of standard functions.
In differential calculus, the derivative of sin (x) is It can become complex or impossible to find the exact
cos(x) and e^x is still e^x derivative of a function when dealing with more complex
Therefore, the derivative of sin(x)+e^x is cos (x) + functions or systems of equations.
e^x with the value of 3.25858413432718 Analytical differentiation may not be computationally efficient
substituting x=1. when working with large data sets or complex numerical
simulations.
02
Purpose and importance
Purpose and importance of numerical
differentiation
Numerical differentiation is an essential tool in
scientific and engineering fields where it is necessary
to estimate the derivatives of complex functions. It
provides a way to calculate the rate of change of a
function and is used to model and analyze systems that
are governed by differential equations. Numerical
differentiation is also useful in optimizing designs and
in estimating the sensitivity of a model to changes in
input variables.
Examples of practical applications:

Economics and
Physics
Finance
Numerical differentiation is used to Numerical differentiation is used to
estimate the velocity and acceleration estimate the sensitivity of a financial
of an object based on its position data model to changes in input variables.
Examples of practical applications:

Engineering Data Analysis Image Processing


Numerical differentiation is used Numerical differentiation is used numerical differentiation is
to analyze and optimize designs to estimate the rate of change of used to enhance and detect
of various systems, such as various physical or biological edges and contours in images.
control systems, signal processes, such as temperature
processing systems, and image changes, chemical reactions, or
processing systems. cell growth.
Practical applications of numerical
differentiation in aerospace
engineering Structural design and analysis
Aerodynamics analysis Flight simulation
vehicle's acceleration and rate of
velocity gradients and design and analysis of aircraft
change of acceleration to determine
pressure gradients around an structures to calculate the stress and
vehicle's position, velocity, and
aircraft or a missile strain distributions
orientation

Control system Propulsion system Trajectory


design design analysis
design of control systems for aircraft design of propulsion systems for Analysis of the vehicle's
and missiles to calculate the rates of aircraft and missiles to calculate the trajectory to calculate the rate
change of various parameters, such as thrust, specific impulse, and other of change of velocity and
velocity, acceleration, and attitude performance parameters acceleration
03 Methods
Methods of Numerical Differentiation
Methods of Numerical
Differentiation
Newton’s Forward

𝑓 ( 𝑥 𝑖 )= Difference
3 𝑓 ( 𝑥 𝑖 )− 4 𝑓 ( 𝑥 𝑖 +h )+ 𝑓 ( 𝑥𝑖 +2 h )
2h

Newton’s Backward

𝑓 ( 𝑥 𝑖 )= Difference
3 𝑓 ( 𝑥𝑖 ) − 4 𝑓 ( 𝑥 𝑖 − h ) + 𝑓 ( 𝑥 𝑖 − 2 h )
2h

Newton’s Central
𝑓 ′ ( 𝑥 𝑖 )= Difference
𝑓 ( 𝑥𝑖 − 2 h ) − 8 𝑓 ( 𝑥𝑖 − h ) +8 𝑓 ( 𝑥 𝑖 +h ) − 𝑓 ( 𝑥𝑖 +2 h )
12 h
Newton’s Forward
Difference Method
Newton’s Forward Difference Method

Newton’s Forward difference method


approximates the derivative of a
function at a point x as the difference
between the function values at x and
x+h, divided by h, where h is a small
positive number.
Procedure for Newton’s Forward
Difference Method for first derivative Use the formula:

− 3 𝑓 ( 𝑥 𝑖 ) + 4 𝑓 ( 𝑥 𝑖 +h ) − 𝑓 (𝑥 𝑖
𝑓 ( 𝑥 𝑖 )=
Determine the step size h, which
2h
Step 1 Step 3
should be the same for all three data
to compute the forward difference
points.
approximation of the first derivative
at xi.

Choose the function f(x)


Evaluate the function at the three data
and the point xi at which to Step 2 points: f(xi), f(xi+h), and f(xi+2h). Step 4
approximate the derivative.

That's it! You can then check the accuracy of the approximation
and adjust the step size if needed.
Newton’s Forward Difference Method
Example
● Approximate the first derivative of the function
f(x) = sin(x) + e^x at the point x = 1, using the
Newton’s forward difference method with h=0.1.
Solution:
Step 1: Choose the function f(x) and the point xi at which to
approximate the derivative. In this case, f(x) = sin(x) + e^x and xi =
1.

Step 2: Determine the step size h as h = 0.1, so xi+2h = 1 + 0.2,


xi+h= 1+ 0.1, and xi = 1.

Step 3: Evaluate the function at the three data points:

f(xi) = f(1) = sin(1) + e^(1) ≈ 3.55975281326694


f(xi + h) = f(1 + 0.1) = sin(1.1) + e^(1.1) ≈ 3.89537338400787
f(xi + 2h) = f(1 + 0.2) = sin(1.2) + e^(1.2) ≈ 4.25215600870377
Solution:
Step 4: Use the formula to compute the forward difference
approximation of the first derivative at xi:

● Therefore, the forward difference approximation of the first


derivative of f(x) = sin(x) + e^x at x = 1 is f’(1) ≈
3.25039543763438.

● Note that the exact value of f’(1) is cos(1) + e^(1) ≈


3.25858413432718, so the approximation is not very
accurate in this case.
Using Excel:
How about the second,
third, forth and so on
derivative?
Newton’s Forward Difference Method
First Derivative

− 3 𝑓 ( 𝑥 𝑖 ) + 4 𝑓 ( 𝑥 𝑖 +h ) − 𝑓 (𝑥 𝑖 +2 h)
𝑓 ( 𝑥 𝑖 )=
Second Derivative 2h
′′
2 𝑓 ( 𝑥 𝑖 ) −5 𝑓 ( 𝑥 𝑖 +h ) +4 𝑓 ( 𝑥 𝑖 +2 h ) − 𝑓 ( 𝑥𝑖 +3 h )
𝑓 ( 𝑥𝑖 )= 2
h
Third Derivative
′ ′′
− 5 𝑓 ( 𝑥 𝑖 ) +18 𝑓 ( 𝑥𝑖 +h ) − 24 𝑓 ( 𝑥𝑖 +2 h ) +14 𝑓 ( 𝑥 𝑖 +3 h ) − 3 𝑓 ( 𝑥 𝑖 +4 h )
𝑓 ( 𝑥𝑖)= 3
2h
Forth Derivative
′ ′′ ′
3 𝑓 ( 𝑥𝑖 ) − 14 𝑓 ( 𝑥 𝑖 +h ) +26 𝑓 ( 𝑥 𝑖 +2 h ) −2 4 𝑓 ( 𝑥𝑖 +3 h ) +11 𝑓 ( 𝑥𝑖 +4 h ) −2 𝑓 ( 𝑥 𝑖 +5 h )
𝑓 ( 𝑥 𝑖 )= 4
h
Same example using Excel:
Newton’s Backward
Difference Method
Newton’s Backward Difference
Method
Newton's Backward Difference Method is a
numerical method used for
approximating the derivative of a
function. It is similar to the Forward
Difference Method, but instead of using
the function values at x and x+h, it uses
the values at x and x-h.
Procedure for Newton’s Backward
Difference Method for first derivative Use the formula:

3 𝑓 ( 𝑥𝑖 ) − 4 𝑓 ( 𝑥 𝑖 − h ) + 𝑓 ( 𝑥 𝑖
𝑓 ( 𝑥 𝑖 )=
Determine the step size h, which
2h
Step 1 Step 3
should be the same for all three data
to compute the backward difference
points.
approximation of the first derivative
at xi.

Choose the function f(x)


Evaluate the function at the three data
and the point xi at which to Step 2 points: f(xi), f(xi-h), and f(xi-2h). Step 4
approximate the derivative.

That's it! You can then check the accuracy of the approximation
and adjust the step size if needed.
Newton’s Backward Difference Method
Example
● Approximate the first derivative of the function
f(x) = sin(x) + e^x at the point x = 1, using the
Newton’s backward difference method with
h=0.1.
Solution:
Step 1: Choose the function f(x) and the point xi at which to
approximate the derivative. In this case, f(x) = sin(x) + e^x and xi =
1.

Step 2: Determine the step size h as h = 0.1, so xi-2h = 1 - 0.2, xi-


h= 1-0.1, and xi = 1.

Step 3: Evaluate the function at the three data points:

f(xi) = f(1) = sin(1) + e^(1) ≈ 3.55975281326694


f(xi - h) = f(1 - 0.1) = sin(0.9) + e^(0.9) ≈ 3.24293002078443
f(xi - 2h) = f(1 - 0.2) = sin(0.8) + e^(0.8) ≈ 2.94289701939199
Solution:
Step 4: Use the formula to compute the backward difference
approximation of the first derivative at xi:

● Therefore, the backward difference approximation of the


first derivative of f(x) = sin(x) + e^x at x = 1 is f’(1) ≈
3.25217688027541.

● Note that the exact value of f’(1) is cos(1) + e^(1) ≈


3.25858413432718, so the approximation is not very
accurate in this case.
Using Excel:
How about the second,
third, forth and so on
derivative?
Newton’s Backward Difference Method
First Derivative

3 𝑓 ( 𝑥𝑖 ) − 4 𝑓 ( 𝑥 𝑖 − h ) + 𝑓 ( 𝑥 𝑖 −2 h)
𝑓 ( 𝑥 𝑖 )=
Second Derivative 2h
′′
2 𝑓 ( 𝑥 𝑖 ) −5 𝑓 ( 𝑥 𝑖 − h ) +4 𝑓 ( 𝑥 𝑖 −2 h ) − 𝑓 ( 𝑥𝑖 − 3 h )
𝑓 ( 𝑥 𝑖 )= 2
h
Third Derivative
′ ′′
5 𝑓 ( 𝑥 𝑖 ) −18 𝑓 ( 𝑥 𝑖 −h )+24 𝑓 ( 𝑥 𝑖 −2 h ) − 14 𝑓 ( 𝑥 𝑖 −3 h ) +3 𝑓 ( 𝑥 𝑖 − 4 h )
𝑓 ( 𝑥𝑖)= 3
2h
Forth Derivative
′ ′′ ′
3 𝑓 ( 𝑥𝑖 ) − 14 𝑓 ( 𝑥 𝑖 −h ) +26 𝑓 ( 𝑥 𝑖 −2 h ) − 2 4 𝑓 ( 𝑥𝑖 − 3 h ) +11 𝑓 ( 𝑥 𝑖 −4 h ) −2 𝑓 ( 𝑥𝑖 −5 h )
𝑓 ( 𝑥 𝑖 )= 4
h
Same example using Excel:
Newton’s Central
Difference Method
Newton’s Central Difference Method

Newton's central difference method is a numerical


approximation method for calculating derivatives
of a function. It is similar to the forward and
backward difference methods, but uses a
symmetric difference formula that takes into
account both the data points to the left and right of
the point of interest.
Procedure for Newton’s Central Difference
Method for first derivative Use the formula:

𝑓 ( 𝑥𝑖 − 2 h ) − 8 𝑓 ( 𝑥𝑖 − h ) +8 𝑓 ( 𝑥 𝑖 +h ) − 𝑓 ( 𝑥𝑖 +2 h)
𝑓 ( 𝑥 𝑖 )=
Step 1 Determine the step size h, which Step 3 12 h
to compute the central difference
should be the same for all four data approximation of the first derivative
points. at xi.

Choose the function f(x) Evaluate the function at the four data
and the point xi at which to Step 2 points: f(xi+h), f(xi+2h). f(xi-h), and Step 4
approximate the derivative. f(xi-2h).

That's it! You can then check the accuracy of the approximation
and adjust the step size if needed.
Example
● Approximate the first derivative of the function
f(x) = sin(x) + e^x at the point x = 1, using the
Newton’s central difference method with h=0.1.
Solution:
Step 1: Choose the function f(x) and the point xi at which to
approximate the derivative. In this case, f(x) = sin(x) + e^x and xi =
1.

Step 2: Determine the step size h as h = 0.1, so xi-2h = 1 - 0.2, xi-


h= 1-0.1, xi+2h = 1 + 0.2, xi+h= 1+0.1 and xi = 1.

Step 3: Evaluate the function at the four data points:

f(xi - h) = f(1 - 0.1) = sin(0.9) + e^(0.9) ≈ 3.24293002078443


f(xi - 2h) = f(1 - 0.2) = sin(0.8) + e^(0.8) ≈ 2.94289701939199
f(xi + h) = f(1 + 0.1) = sin(1.1) + e^(1.1) ≈ 3.89537338400787
f(xi + 2h) = f(1 + 0.2) = sin(1.2) + e^(1.2) ≈ 4.25215600870377
Solution:
Step 4: Use the formula to compute the central difference
approximation of the first derivative at xi:

● Therefore, the central difference approximation of the first


derivative of f(x) = sin(x) + e^x at x = 1 is f’(1) ≈
3.25857326372975.

● Note that the exact value of f’(1) is cos(1) + e^(1) ≈


3.25858413432718, so the approximation is not very accurate in
this case.
Using Excel:
How about the second,
third, forth and so on
derivative?
Newton’s Central Difference Method
First Derivative

𝑓 ( 𝑥𝑖 − 2 h ) − 8 𝑓 ( 𝑥𝑖 − h ) +8 𝑓 ( 𝑥 𝑖 +h ) − 𝑓 ( 𝑥𝑖 +2 h)
𝑓 ( 𝑥 𝑖 )=
Second Derivative 12 h
′′
− 𝑓 ( 𝑥𝑖 − 2 h ) +16 𝑓 ( 𝑥 𝑖 −h ) − 30 𝑓 ( 𝑥 𝑖 ) +16 𝑓 ( 𝑥𝑖 + h ) − 𝑓 (𝑥𝑖 + 2 h)
𝑓 ( 𝑥𝑖 )= 2
12 h
Third Derivative
′ ′′
𝑓 ( 𝑥 𝑖 − 3 h ) − 8 𝑓 ( 𝑥 𝑖 −2 h ) +13 𝑓 ( 𝑥𝑖 − h ) −1 3 𝑓 ( 𝑥 𝑖 +h ) +8 𝑓 ( 𝑥 𝑖 +2 h ) − 𝑓 ( 𝑥𝑖 +3 h )
𝑓 ( 𝑥𝑖)= 3
8h
Forth Derivative
′ ′′ ′
− 𝑓 ( 𝑥 𝑖 −3h ) +12 𝑓 ( 𝑥 𝑖 −2h ) −39 𝑓 ( 𝑥 𝑖 −h ) +56 𝑓 ( 𝑥𝑖 ) −39 𝑓 ( 𝑥 𝑖 +h ) +12 𝑓 ( 𝑥 𝑖 +2h ) − 𝑓 ( 𝑥 𝑖+3h )
𝑓 ( 𝑥 𝑖 )= 4
6h
Same example using Excel:
04
Comparison of
Methods
Comparison of Methods of Numerical Differentiation
Comparison of Methods
● After examining the examples of forward difference, backward difference, and
central difference methods, we can compare their results and accuracy.

● In Example 1, the forward difference method produced an approximation of f’(1)


equal to 3.25039543763438 with a step size of h = 0.1. The error of the
approximation was 0.2513%.

● In Example 2, the backward difference method produced an approximation of f’(1)


equal to 3.25217688027541 with a step size of h = 0.1. The error of the
approximation was 0.19663%.

● In Example 3, the central difference method produced an approximation of f’(1)


equal to 3.25857326372975 with a step size of h = 0.1. The error of the
approximation was 0.00033%.
Excel
Factors to consider when choosing a
method: Complexity Smoothness of
Accuracy Consider the the function
Choose a method that provides computational resources
Consider the smoothness
results that are accurate enough required to implement the
of the function being
for the intended application. method.
differentiated.

Factors
Stability Convergence Availability of
Choose a stable method that can
handle small errors in the data. Choose a method that
data
converges quickly to the
Consider the availability
exact value as the step size
and quality of the data
is decreased.
required by the method.
Summary
differentiation
Accuracy
Numerical

Numerical differentiation Stability

Factors
approximates the Complexity
derivative of a function Convergence
using numerical methods. Smoothness of the function
Availability of data.

differentiatio
differentiatio
n methods

n methods

numerical
numerical

Newton’s Forward Difference - uses a forward shift


Newton’s Backward Difference - uses a backward shift
Newton’s Central Difference - uses a symmetric shift.
Conclusions
In conclusion, numerical differentiation is a vital tool for approximating derivatives of
functions in various fields. In this presentation, we covered the three common numerical
differentiation methods: forward difference, backward difference, and central difference.
Each method uses a different approach to approximate the derivative and has its advantages
and limitations. It's crucial to consider factors such as accuracy, stability, complexity,
convergence, smoothness of the function, and availability of data when choosing a method.
We also discussed practical applications of numerical differentiation in aerospace,
engineering, and physics, and how continued research and development in numerical
differentiation methods will continue to play a significant role in the advancement of science
and technology.

You might also like