lecture 3 updated
lecture 3 updated
1
COURSE OUTLINE
• Modelling, Computers & Error Analysis.
• Linear Algebraic & Non-linear Equations.
• Finite difference methods and interpolation.
• Numerical differentiation and integration.
• Numerical solution of ordinary differential equations.
• Numerical solution of partial differential equations.
2
Learning objectives
• At the end of the lecture, students must be able to deal with a wide
variety of engineering problems dealing with roots of equation.
3
NON-LINEAR EQUATIONS
ROOTS AND THEIR APPROXIMATION
• All nonlinear equations can be written in the general form
𝑓 𝑥 =0 (1.1)
• where x is a single variable that can have multiple values (roots) that satisfy this equation.
• The function 𝑓(𝑥) may assume a variety of nonlinear functionalities such as a polynomial
equation whose canonical form is
𝑓 𝑥 = 𝑎𝑛 𝑥 𝑛 + 𝑎𝑛−1 𝑥 𝑛−1 +. . . +𝑎1 𝑥 + 𝑎0 = 0
• Or transcendental equations, which involve trigonometric, exponential, and logarithmic
terms.
𝑓 𝑥 = 𝑙𝑛𝑥 2 − 1 and 𝑓 𝑥 = 𝑒 −0.2𝑥 sin(3𝑥 − 0.5)
22
NON-LINEAR EQUATIONS
ROOTS AND THEIR APPROXIMATION
Direct methods
• Gives values of all the roots in a finite number of steps
Eg roots of quadratic equations 𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0, 𝑎 ≠ 0
Can be obtained by:
1
𝑥= −𝑏 ± 𝑏 2 − 4𝑎𝑐
2𝑎
22
GRAPHICAL METHODS
• A simple method for obtaining an estimate of the root of the equation
f (x) = 0 is to make a plot of the function and observe where it crosses
the x axis.
• This point, which represents the x value for which f (x) = 0, provides a
rough approximation of the root.
24
GRAPHICAL METHODS
𝑥 4 + 6𝑥 3 + 7𝑥 2 − 6𝑥 − 8 = 0
2. Open Methods: one or more initial guess, no need for them to bracket the
root
a. Fixed-point iteration method
b. Newton-Raphson
c. Secant method
d. Wegsteins’s method
NON LINEAR EQUATIONS
Iterative methods
1a Bisection method
Step 1:
choose lower 𝑥𝑙 and upper 𝑥𝑢 guesses for the root such that the
function changes signs over the interval. This can be checked by
ensuring that 𝑓(𝑥𝑙 ). 𝑓 𝑥𝑢 < 0
Step 2
An Estimate of the root 𝑥𝑟 is determined by
𝑥𝑙 + 𝑥𝑢
𝑥𝑟 =
2
Bisection method
Step 3:
Make the following evaluations to determine in which
subinterval the root lies:
i. 𝑓(𝑥𝑙 ). 𝑓 𝑥𝑟 < 0, the root lies in the lower
subinterval therefore, 𝑥𝑢 = 𝑥𝑟 And return to step 2
ii. If 𝑓(𝑥𝑙 ). 𝑓 𝑥𝑟 > 0 the root lies in the upper
subinterval therefore, 𝑥𝑙 = 𝑥𝑟 And return to step 2
iii. If 𝑓(𝑥𝑙 ). 𝑓 𝑥𝑟 = 0 the root equals 𝑥𝑟 ; terminate
the computation
𝑥𝑟𝑛𝑒𝑤 − 𝑥𝑟𝑜𝑙𝑑
𝜺𝒂 = 𝑛𝑒𝑤 × 100%
𝑥𝑟
Bisection method
• Example:
• Use the bisection method to find the root of the function below
𝑓(𝑥) = 𝑒 𝑥 𝑠𝑖𝑛𝑥 − 2
on the interval [3,4] given 𝜺𝒔 = 𝟎. 𝟓% (to be solved in class)
1b. Regula Falsi (method of false position/linear
interpolation method)
Step 1:
choose lower 𝑥𝑙 and upper 𝑥𝑢 guesses for the
root such that the function changes signs
over the interval. This can be checked by
ensuring that 𝑓(𝑥𝑙 ). 𝑓 𝑥𝑢 < 0
Step 2
An Estimate of the root 𝑥𝑟 is determined by
𝑓(𝑥𝑢 ) (𝑥𝑙 − 𝑥𝑢 )
𝑥𝑟 = 𝑥𝑢 −
𝑓 𝑥𝑙 − 𝑓(𝑥𝑢 )
Try:
• Use the Regula Falsi method to find the root of the function below
𝑓(𝑥) = 𝑒 𝑥 𝑠𝑖𝑛𝑥 − 2
on the interval [3,4] given 𝜺𝒔 = 𝟎. 𝟓%
Fixed-point iteration method
• The simplest one-point iterative root-finding technique
can be developed by rearranging the function 𝑓(𝑥) so
that x is on the left-hand side of the equation
𝑥=𝑔 𝑥 (3.1)
• The function 𝑔(𝑥) is a formula to predict the root.
• This transformation can be obtained by algebraic
manipulation or by adding x to both sides of the
equation
• For example:
sin 𝑥 = 0 becomes 𝑥 = 𝑠𝑖𝑛𝑒 𝑥 + 𝑥
𝑒 −𝑥 − 𝑥 = 0 becomes 𝑥 = 𝑒 −𝑥 NB: Fixed point Iteration will
• Starting with an initial value of xi, we obtain the value of only converge if
xi+1: 𝒈′ 𝒙 < 𝟏
𝑥𝑖+1 = 𝑔 𝑥𝑖 (3.12)
Fixed-point iteration method
• Example
Use fixed point iteration to locate the root of 𝑓 𝑥 = 𝑒 −𝑥 − 𝑥
Solution:
The function can be separated directly into 𝑥𝑖+1 = 𝑒 −𝑥𝑖
Thus each iteration brings the estimate closer to the true value of 0.56714329
TEST 2
• The most widely used, technique • If the initial guess at the root is xi, a
for locating roots of nonlinear tangent can be extended from the
equations is the Newton-Raphson point [xi, f(xi)].
method. • The point where this tangent
crosses the x axis usually represents
an improved estimate of the root
(xi+1).
′ 𝑓 𝑥𝑖 −0
• 𝑓 𝑥𝑖 = rearranging
𝑥𝑖 −𝑥𝑖+1
gives:
𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − (4.1)
𝑓′ (𝑥𝑖 )
33
THE NEWTON-RAPHSON METHOD
• Newton-Raphson method can also be derived from the Taylor series.
′′ 𝒏
′
𝒇 𝒙 𝒊 2
𝒇 𝒙𝒊 𝒏
𝒇 𝒙𝒊+𝟏 = 𝒇 𝒙𝒊 + 𝒇 𝒙𝒊 (𝑥𝑖+1 − 𝑥𝑖 ) + (𝑥𝑖+1 − 𝑥𝑖 ) + ⋯ + 𝒉 + 𝑹𝒏
𝟐! 𝒏!
• An approximate version is obtainable by truncating the series after the first derivative
term. At an intersection with the x-axis, 𝒇 𝒙𝒊+𝟏 = 𝟎
0 = 𝒇 𝒙𝒊 + 𝒇′ 𝒙𝒊 (𝑥𝑖+1 − 𝑥𝑖 )
𝑓(𝑥𝑖 )
• Rearranging results 𝑥𝑖+1 = 𝑥𝑖 − ′
𝑓 (𝑥𝑖 )
NB: Newton-Raphson method performs poorly for some selected functions (slow
convergence) as its convergence depends on the nature of the function and on the accuracy
of the initial guesses. Initial guess must be sufficiently close to the root as possible.
35
EXAMPLE
37
SOLUTION
𝑓 ′ 𝑥𝑖 = −𝑒 −𝑥𝑖 − 1
38
Graphical depiction of the secant method.
THE SECANT METHOD
41
Finite divided difference
• From the Taylor series first derivatives can be approximated numerically by
truncating the expansion after the first term. This can be done in 3 ways:
𝒇 𝒙𝒊+𝟏 = 𝒇 𝒙𝒊 + 𝒇′ 𝒙𝒊 (𝑥𝑖+1 − 𝑥𝑖 )
𝒇 𝒙𝒊+𝟏 −𝒇 𝒙𝒊
𝒇′ 𝒙𝒊 = or
(𝑥𝑖+1 −𝑥𝑖 )
𝒇 𝒙𝒊+𝟏 −𝒇 𝒙𝒊
𝒇′ 𝒙𝒊 =
𝒉
Finite divided difference
2.Backward divided difference: Calculates the derivative based on the
previous value and current value. It utilizes the data at 𝑥𝑖−1 and 𝑥𝑖
′
𝒇 𝒙𝒊 − 𝒇 𝒙𝒊−𝟏
𝒇 𝒙𝒊 ≅
𝒉
Finite divided difference
3. Centered difference approximation: Calculates the derivative based
on step values on both sides of the point. It utilizes the data at 𝑥𝑖−1 and
𝑥𝑖+1
𝒇 𝒙𝒊−𝟏 − 𝒇 𝒙𝒊+𝟏
𝒇′ 𝒙𝒊 ≅
𝟐𝒉
Example:
5 0.84
10 0.72
Use the centered finite approximation to estimate 30 0.47
𝑑𝐶𝐴 (𝑡)
45 0.37
𝑑𝑡
At t=20 min using a step size h=10. 60 0.3