3/15/21
KA20602 NUMERICAL ANALYSIS
Chapter 1
INTRODUCTION TO NUMERICAL ANALYSIS
AHMAD NURFAIDHI RIZALMAN (PhD)
Civil Engineering Programme
, No. 66 Level 2 Block A, Faculty of Engineering
( 088 – 320000 (ext. 3033) + [email protected]
Prepared by: Ahmad Nurfaidhi Rizalman
CONTENT
q Introduction to Numerical Method
q Significant Figures, Accuracy and Precision
q Round-off Error
q Truncation Error
q Error Analysis
Sample Questions
Solution to Exercise
Prepared by: Ahmad Nurfaidhi Rizalman
1
3/15/21
INTRODUCTION
Prepared by: Ahmad Nurfaidhi Rizalman
INTRODUCTION
There are three (3) methods to solve engineering problems:
Experiment Simulation Mathematical Model
Outcome is expressive but Define and solve the Expresses the problems in
involves lots of equipment problems graphically to mathematical terms (i.e.
and facilities which are characterize the behavior of formula). Solutions are
expensive. systems. derived analytically or
numerically.
Prepared by: Ahmad Nurfaidhi Rizalman
2
3/15/21
INTRODUCTION
There are two (2) types of mathematical models
ANALYTICAL NUMERICAL
• Produce exact solutions. • Produce approximate solutions.
• Limited to linear problems with simple • Capable to solve nonlinear problems
geometry and low dimensionality. with complex shapes and high
dimensionality.
• Thus, it involves large numbers of
tedious arithmetic calculations.
• This method has increased dramatically
due to the development of digital
computers and software, i.e. MATLAB,
Excel, SPSS, and etc.
Prepared by: Ahmad Nurfaidhi Rizalman
INTRODUCTION
There are eight (8) types of numerical methods, including
a) Nonlinear Equations (Roots of Equations).
b) Linear Equations
c) Optimization
d) Curve Fitting
e) Interpolation
f) Numerical Differentiation and Integration
g) Ordinary Differential Equations
h) Partial Differential Equations
Prepared by: Ahmad Nurfaidhi Rizalman
3
3/15/21
INTRODUCTION
a) Nonlinear Equations (Roots of Equations)
These problems are concerned with the value of
a variable or a parameter that satisfies a single
nonlinear equations. (i.e. solve 𝑓 𝑥 = 0 for 𝑥).
They are valuable in engineering design contexts
where it is often impossible to explicitly solve
design equations for parameters.
Prepared by: Ahmad Nurfaidhi Rizalman
INTRODUCTION
b) Linear Algebraic Equations
They are also concerned with values that satisfy
equations. But, in this approach, a set of values is
sought that simultaneously satisfies a set of linear
algebraic equations.
Such problems include mathematical modelling
of large systems of interconnected elements such
as structures and fluid networks.
For instance, given the 𝑎’s and the 𝑐′s, solve
𝑎!!𝑥! + 𝑎!"𝑥" = 𝑐!
𝑎"!𝑥! + 𝑎""𝑥" = 𝑐"
for the 𝑥’s.
Prepared by: Ahmad Nurfaidhi Rizalman
4
3/15/21
INTRODUCTION
c) Optimization
The problem involve determining value(s) of an
independent variable that correspond to a “best,”
or optimal, value of a function.
For instance, in the figure above, the optimization
involves identifying maxima and minima.
Prepared by: Ahmad Nurfaidhi Rizalman
INTRODUCTION
d) Curve Fitting
Curve fitting (or regression) is employed where
there is a significant degree of error associated
with the data.
Experimental results are often of this kind. It is
done by deriving a single curve that represent the
general trend of the data without matching any
individual points.
Prepared by: Ahmad Nurfaidhi Rizalman
10
5
3/15/21
INTRODUCTION
e) Interpolation
Interpolation is used where the objective is to
determine intermediate values between
relatively error-free data points.
Such is usually the case for tabulated information.
It is done by fitting a curve directly through the
data points and use the curve to predict the
intermediate values.
Prepared by: Ahmad Nurfaidhi Rizalman
11
INTRODUCTION
f) Numerical Differentiation and Integration
Numerical integration is determination of the
area under a curve.
For instance, the determination of the centroids
of an object. In addition, it plays an important
role in the solution of differential equations.
For example, to find the area of the curve, the
following equations are employed.
$
𝐼 = ∫# 𝑓 𝑥 𝑑𝑥
Prepared by: Ahmad Nurfaidhi Rizalman
12
6
3/15/21
INTRODUCTION
g) Ordinary Differential Equations
ODE are of great significance in engineering
practice. For instance, the acceleration of a falling
body (rate of change of velocity).
Two types of problems are addressed: initial-
value and boundary-value problems. It also
include the computation of eigenvalues.
Given
%& (&
%'
≈ ()
= 𝑓(𝑡, 𝑦)
Solve for 𝑦 as a function of 𝑡.
𝑦*+! = 𝑦* + 𝑓 𝑡* , 𝑦* ∆𝑡
Prepared by: Ahmad Nurfaidhi Rizalman
13
INTRODUCTION
h) Partial Differential Equations
They are used to characterize engineering
systems where the behavior of a physical quantity
is couched in terms of its rate of change with
respect to two or more independent variables.
The common approaches include finite difference
method and finite element method.
For instance, solve for 𝑢 as a function of 𝑥 and 𝑦.
,! - ,! -
,' ! + ,&!
= 𝑓(𝑥, 𝑦)
Prepared by: Ahmad Nurfaidhi Rizalman
14
7
3/15/21
SIGNIFICANT FIGURE, ACCURACY AND PRECISION
Prepared by: Ahmad Nurfaidhi Rizalman
15
SIGNIFICANT FIGURE, ACCURACY AND PRECISION
• Significant figures (or digit) is defined as numbers that can be used with confidence.
They correspond to the number of certain digits plus one estimate digit.
• The concept of significant figures will have relevance to the definition of accuracy
and precision.
Prepared by: Ahmad Nurfaidhi Rizalman
16
8
3/15/21
QUESTION 1.1
How many significant figures in the following numbers?
a) 0.01688
b) 0.001688
c) 0.0001688
d) 0.000000001688
e) 37900
f) 3.79 x 104
g) 3.790 x 104
h) 3.7900 x 104
Prepared by: Ahmad Nurfaidhi Rizalman
17
SOLUTIONS TO QUESTION 1.1
(a) – (d) all have four significant figures.
(e) 37900 may have three, four, or five significant figures, depending on whether the
zeros are known with confidence.
(f), (g) and (h) are three, four, or five significant figures, respectively.
Prepared by: Ahmad Nurfaidhi Rizalman
18
9
3/15/21
SIGNIFICANT FIGURE, ACCURACY AND PRECISION
Increasing accuracy Accuracy refers to how close a
particular measurement to the
Inaccurate Accurate
exact value, while precision
and and refers to consistency of
repeated measurement.
Increasing precision
imprecise imprecise
Thus, the best measurement is
accurate and precise.
From the figure, the arrow on
Inaccurate Accurate each target can be taught as
and precise and precise the prediction of a numerical
technique, and the bull’s eye is
the exact value.
Prepared by: Ahmad Nurfaidhi Rizalman
19
SIGNIFICANT FIGURE, ACCURACY AND PRECISION
• In numerical methods (analysis), the results obtained should be sufficiently accurate to
meet the requirements of a particular engineering problems. They should also be precise
enough for adequate engineering design.
• But, since the numerical methods to obtain approximate solutions, it is expected the
results consist of certain errors. There are two (2) major form of unavoidable numerical
errors – (1) Round-off Errors, and (2) Truncation Errors.
Prepared by: Ahmad Nurfaidhi Rizalman
20
10
3/15/21
ROUND-OFF ERRORS
Prepared by: Ahmad Nurfaidhi Rizalman
21
ROUND-OFF ERROR
• Round-off error arise when the numbers having limited significant figures are used
to represent exact numbers.
• Some numbers cannot be expressed by a fixed number of significant figures such as
!
.
= 0.3333333 … , 𝑒 = 2.71828182 … . and 𝜋 = 3.1415926.
• In the calculations, round-off errors occur when the digits to the right of the decimal
are discarded. Say for and 𝜋 computer can store 4 significant figures. Therefore,
a) Chopping-off à 𝜋 = 3.1415
b) Rounding-off à 𝜋 = 3.1416
Prepared by: Ahmad Nurfaidhi Rizalman
22
11
3/15/21
QUESTION 1.2
Perform each of the computation below (i) exactly, (ii) using four-digit chopping
arithmetic, and (iii) four-digit rounding arithmetic.
. 0
a) / + 1
. 0
b) /
−1
Prepared by: Ahmad Nurfaidhi Rizalman
23
SOLUTIONS TO QUESTION 1.2
Solutions to 1.2a)
. 0 !!
(i) /
+ 1
= 1 2"
. 0
(ii) /
+ 1 = 1.261904 … ≈ 1.261
. 0
(iii) /
+ 1 = 1.261904 … ≈ 1.262
Solution for 1.2b)
. 0 !/
(i) /
− 1
= − 2"
. 0
(ii) − = −0.404761 … ≈ −0.4047
/ 1
. 0
(iii) /
− 1 = −0.404761 … ≈ −0.4048
Prepared by: Ahmad Nurfaidhi Rizalman
24
12
3/15/21
QUESTION 1.3
Given an irrational number 𝜋 = 3.141592654 …, find the five-digit representations of 𝜋
by
a) Chopping-off technique,
b) Rounding-off technique.
Prepared by: Ahmad Nurfaidhi Rizalman
25
SOLUTIONS TO QUESTION 1.3
a) Chopping-off: 𝜋 ≈ 0.31415×10!
b) Rounding-off: 𝜋 ≈ 0.31416×10!
Prepared by: Ahmad Nurfaidhi Rizalman
26
13
3/15/21
TRUNCATION ERROR
Prepared by: Ahmad Nurfaidhi Rizalman
27
TRUNCATION ERROR
• Truncation error arise when approximation are used to represent exact mathematical
procedure or expression. It originates from the technique of replacing a complicated
function with a truncated Taylor series. For example, the infinite Taylor series of
'! '" '# '$ '%
𝑒 ' = 1 + 𝑥 + "! + .! + 2! + 0! + ⋯ + 4!
might be replaced with just first five terms
'! '" '#
𝑒 ' ≈ 1 + 𝑥 + "! + .! + 2!
• Truncation error is introduced whenever a number computational uses a formula
involving discrete values. Unlike round-off error, which is controlled by the hardware and
computer language, truncation error is under the control of the programmer.
Prepared by: Ahmad Nurfaidhi Rizalman
28
14
3/15/21
QUESTION 1.4
!/" !
Given that ∫5 𝑒 ' 𝑑𝑥 = 0.544987104184. Find the approximation by replacing the
! '# '& ''
integrand 𝑓 𝑥 = 𝑒 ' with the truncated Taylor series 𝑒 ' ≈ 1 + 𝑥 " + "!
+ .!
+ 2!
.
Give the answer in 3 decimal places using round-off technique.
Prepared by: Ahmad Nurfaidhi Rizalman
29
SOLUTIONS TO QUESTION 1.4
!/" ! !/" '# '& ''
∫5 𝑒 ' 𝑑𝑥 ≈ ∫5 1 + 𝑥" + "!
+ .!
+ 2!
𝑑𝑥 Term-by term integration, yields
':!/"
'" '$ '( ')
= 𝑥+ .
+ 0("!) + /(.!) + 9(2!)
':5
! ! ! ! !
= " + "".. + "$.0("!) + "(./(.!) + ").9(2!)
! ! ! ! !
= " + "2 + ."5 + 0./1 + !!509"
= 0.54498672
≈ 0.545.
Prepared by: Ahmad Nurfaidhi Rizalman
30
15
3/15/21
ERROR ANALYSIS
Prepared by: Ahmad Nurfaidhi Rizalman
31
ERROR ANALYSIS
In the practice of numerical analysis, it is important to note that computed solutions are
not exact mathematical solutions. Perfect accuracy in most computational processes is
impossible. Therefore, it is imperative to make certain approximations, thus called as
errors.
The error in a computed quantity is defined by the relationship between exact solution (or
true value) and the approximate value. It is expressed as follows:
Error = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑣𝑎𝑙𝑢𝑒
= 𝑥) − 𝑥#
Absolute Error = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑣𝑎𝑙𝑢𝑒
= 𝑥) − 𝑥#
Prepared by: Ahmad Nurfaidhi Rizalman
32
16
3/15/21
ERROR ANALYSIS
The relative error is a measure of the error in relation to the size of the true being sought.
Mathematically, it is expressed as:
<==>=
Relative Error = )=-< ?#@-<
'" A'#
= '$
True percent
)=-< ?#@-< A#BB=>'*C#)< ?#@-<
relative error, 𝜀) = )=-< ?#@-<
× 100%
Approximate percent
B=<D<4) #BB=>'*C#)*>4 AB=<?*>-D #BB=>'*C#)*>4
relative error, 𝜀# = B=<D<4) #BB=>'*C#)*>4
×100%
Prepared by: Ahmad Nurfaidhi Rizalman
33
QUESTION 1.5
Find the absolute error and relative error for values given below:
a) Let 𝑥E = 3.141592 and 𝑥F = 3.14
b) Suppose that the true value is 1000000 and our estimation is 999996.
.
c) The answer obtained from analytical solution is ; meanwhile the answer
"05555
from from numerical method is 0.000009.
Prepared by: Ahmad Nurfaidhi Rizalman
34
17
3/15/21
SOLUTIONS TO QUESTION 1.5
a) Absolute error = 𝑥) − 𝑥#
= 3.141592 − 3.14
= 0.001592
'" A'#
Relative error = '"
5.55!09"
= ..!2!09"
≈ 0.000507
b) Absolute error = 1000000 − 999996
=4
2
Relative error = !555555
= 0.000004
Prepared by: Ahmad Nurfaidhi Rizalman
35
SOLUTIONS TO QUESTION 1.5
.
c) Absolute error = "05555 − 0.000009
= 0.000003
5.55555.
Relative error = 5.5555!"
= 0.25
Prepared by: Ahmad Nurfaidhi Rizalman
36
18
3/15/21
QUESTION 1.6
Suppose that you have the task of measuring the length of a table and a handphone,
from measurement, you got 110.0 𝑐𝑚 and 11.0 𝑐𝑚, respectively. Find
a) Absolute error,
b) Relative error (in percentage), for each case.
Prepared by: Ahmad Nurfaidhi Rizalman
37
SOLUTIONS TO QUESTION 1.6
a) The absolute error for measuring the table is:
𝑥) − 𝑥# = 110.0 − 109.5 = 0.5 𝑐𝑚.
The absolute error for measuring the handphone is:
𝑥) − 𝑥# = 11.0 − 10.5 = 0.5 𝑐𝑚.
b) The relative error for measuring the table is
' A' 5.0
= "' # = !59.0 ≈ 0.000456 = 0.0456%.
"
The relative error for measuring the handphone is
' A' 5.0
= "' # = !5.0 ≈ 0.0476 = 4.76%.
"
Prepared by: Ahmad Nurfaidhi Rizalman
38
19
3/15/21
SAMPLE QUESTIONS
Prepared by: Ahmad Nurfaidhi Rizalman
39
QUESTION 1.7
How many significant figures in the following numbers?
a) 929
b) 0.0929
c) 0.00929
d) 0.00000000929
e) 512000
f) 5.12 x 105
g) 5.120 x 105
h) 5.12000 x 105
Solution:
a) - d): Three significant figures
e) may have three, four, five or six significant figures.
f), g) and h) are three, four, or six significant figures, respectively.
Prepared by: Ahmad Nurfaidhi Rizalman
40
20
3/15/21
QUESTION 1.8
Perform each of the computation below (i) exactly, (ii) using three-digit chopping arithmetic,
and (iii) three-digit rounding arithmetic.
2 !
a) 0
+ .
2 !
b) ×
0 .
Solution:
"
a)(i) 1 !0 (ii) 1.13 (iii) 1.13
b)(i) 4⁄15 (ii) 0.266 (iii) 0.267
Prepared by: Ahmad Nurfaidhi Rizalman
41
QUESTION 1.9
Find the representation of the following numbers by chopping–off technique and rounding-off
technique.
a) 97450677
b) e = 2.718281828
c) 0.2553075606
d) mn = 1.67492716 x 10-27
Solution:
a)(i) 97450600 (ii) 97450700
b)(i) 2.71828 (ii) 2.71828
c)(i) 0.255307 (ii) 0.255308
d)(i) 1.67492 ×10A"/ (ii)1.67493 ×10A"/
Prepared by: Ahmad Nurfaidhi Rizalman
42
21
3/15/21
QUESTION 1.10
!/2 ' !
Given that ∫5 𝑒 𝑑𝑥 = 0.2553074606 . Find the approximation by replacing the integrand
! ! '% '&
𝑓 𝑥 = 𝑒 ' with the truncated Taylor series 𝑒 ' ≈ 1 + 𝑥 " + "!
+ .!
. Give the answer in 3
decimal places using round-off technique.
Solution:
0.255
Prepared by: Ahmad Nurfaidhi Rizalman
43
QUESTION 1.11
Find the absolute error and relative error for values given below:
a) Let 𝑥E = 2.7182818 and 𝑥F = 2.7182.
b) Suppose that the true value is 97450 and the estimation is 97000.
c) The answer obtained from analytical solution is 0.000764, meanwhile the answer from
numerical method is 0.000760.
Solution:
a) 0.0000818, 0.00003009
b) 450, 0.004618
c) 0.000004, 0.0005236
Prepared by: Ahmad Nurfaidhi Rizalman
44
22
3/15/21
QUESTION 1.12
If 𝑥 = 2 is approximated by 𝑥̅ = 1.94, find the true error and relative error.
Solution:
True error = 0.06, Relative error = 0.03
Prepared by: Ahmad Nurfaidhi Rizalman
45
QUESTION 1.13
.
If 𝑥 = 𝜋 is approximated by 𝑥̅ = /, find the actual error and relative percent error.
Solution:
True error = 2.71302, Relative percent error = 86.36%
Prepared by: Ahmad Nurfaidhi Rizalman
46
23
3/15/21
QUESTION 1.14
Given a function 𝑓 𝑥 = sin(𝑥) . Compute the following Taylor’s polynomial at 𝑥 = 0 for
a) 𝑃! 𝑥 , 𝑃" 𝑥 , 𝑃.(𝑥), and 𝑃G(𝑥),
b) If the above Taylor’s polynomial is used to approximates 𝑠𝑖𝑛 27> , then find the true error
𝐸) of each of these approximations.
Prepared by: Ahmad Nurfaidhi Rizalman
47
SOLUTIONS TO QUESTION 1.14
a) Since 𝑥5 = 0, then
! ! !
𝑃4 𝑥 = 𝑓 0 + 𝑓 H 0 𝑥 + " 𝑓 HH 0 𝑥 " + .! 𝑓 . 0 𝑥 . + ⋯ + 4! 𝑓 4 (0)(𝑥)4
!
= ∑4I:5 I! 𝑓 I (0)(𝑥)I .
A systematic way to calculate these polynomials is by constructing a table for the derivatives.
! ! ! !
Therefore 𝑃! 𝑥 = 0, 𝑃" 𝑥 = 𝑥, 𝑃. 𝑥 = 𝑥 − 1 𝑥 . and 𝑃G 𝑥 = 𝑥 − 1 𝑥 . + !"5 𝑥 0 − 0525 𝑥 /.
b) The true value sin 275 = 0.4540. To use these polynomials to approximate sin 27> , we
J
need to take 𝑥 in radians as 𝑥 = 27> × "/' = 0.4712. Hence, the solution is
𝑠𝑖𝑛 27> − 𝑃! 27> = 0.4540
𝑠𝑖𝑛 27> − 𝑃" 27> = 0.0172
𝑠𝑖𝑛 27> − 𝑃. 27> = 0.0002
𝑠𝑖𝑛 27> − 𝑃G 27> = 3.4662 × 10A0
Prepared by: Ahmad Nurfaidhi Rizalman
48
24
3/15/21
QUESTION 1.15
Find the second and fourth order Taylor’s polynomial, 𝑃"(𝑥) and 𝑃2(𝑥), centered at 𝑥 = 𝑥5, for
each of the following functions
a) 𝑓 𝑥 = 𝑒 ' , 𝑥5 = 1
(
b) 𝑓 𝑥 = 𝑥 ) , 𝑥5 = 5
Prepared by: Ahmad Nurfaidhi Rizalman
49
SOLUTIONS TO QUESTION 1.15
a)
!
𝑃" 𝑥 = 𝑒 ! 1 + 𝑥 − 1 + " (𝑥 − 1)"
1 1 1 1
𝑃0 𝑥 = 𝑒 ! 1 + 𝑥 − 1 + (𝑥 − 1)"+ (𝑥 − 1).+ (𝑥 − 1)2+ (𝑥 − 1)0
2 6 24 120
b)
1 2
𝑃" 𝑥 = 5!/. 1 + 5A! 𝑥 − 5 − 5A"(𝑥 − 5)"
3 18
𝑃" 𝑥
1 2 5 A. 5
= 5!/. Q1 + 5A! 𝑥 − 5 − 5A"(𝑥 − 5)"+ 5 (𝑥 − 5).− 5A2 𝑥 − 5 2
3 18 162 1458
11
+ 5A0(𝑥 − 5)0R
104976
Prepared by: Ahmad Nurfaidhi Rizalman
50
25
3/15/21
QUESTION 1.16
Compute the following Taylor’s polynomial, 𝑃4 (𝑥) centered at 𝑥 = 0 of 𝑦 = cos 𝑥 " for
a) 𝑃!(𝑥)
b) 𝑃"(𝑥)
c) 𝑃2(𝑥)
Prepared by: Ahmad Nurfaidhi Rizalman
51
SOLUTIONS TO QUESTION 1.16
𝑛 𝑓 4 (𝑥) 𝑓 4 (0)
0 cos 𝑥 " 1
1 −2𝑥 sin 𝑥 " 0
2 −4𝑥 " cos 𝑥 " − 2 sin 𝑥 " 0
3 8𝑥 . sin 𝑥 " − 12𝑥 𝑐𝑜𝑠 𝑥 " 0
4 16𝑥 2 cos 𝑥 " + 48𝑥 " sin 𝑥 " − 12 cos 𝑥 " −12
!" 2
Therefore 𝑃2 𝑥 = 1 − "2 𝑥
Prepared by: Ahmad Nurfaidhi Rizalman
52
26
3/15/21
QUESTION 1.17
A civil engineer has measured the height of a 15 floor building as 3940 m and the working
height of each beam as 35 m while the true values are 3945 m and 40 m, respectively.
Compare their true error and true percent relative error.
Prepared by: Ahmad Nurfaidhi Rizalman
53
SOLUTIONS TO QUESTION 1.17
True error in measuring the height of the building =5m
True percent relative error in measuring the height of the building = 0.13%
True error in measuring the height of the beam =5m
True percent relative error in measuring the height of the beam = 13%
Although the true errors are the same, the true percent relative errors differ by 100%. Hence,
there is something wrong in the measurement of the height of the beam by using true error.
Thus, it should be done more accurately.
Prepared by: Ahmad Nurfaidhi Rizalman
54
27