0% found this document useful (0 votes)
11 views22 pages

Week2.1 - MATLAB, Approximation and Error, Roots of Equations

The document outlines the topics covered in Week 2 of the Engineering Analysis and Computation course, focusing on MATLAB programming, approximation and error analysis, and roots of equations. It discusses significant figures, accuracy and precision, and various types of numerical errors, including truncation and round-off errors. The content emphasizes the importance of understanding error estimates in numerical methods, especially when analytical solutions are not available.

Uploaded by

youssefsamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views22 pages

Week2.1 - MATLAB, Approximation and Error, Roots of Equations

The document outlines the topics covered in Week 2 of the Engineering Analysis and Computation course, focusing on MATLAB programming, approximation and error analysis, and roots of equations. It discusses significant figures, accuracy and precision, and various types of numerical errors, including truncation and round-off errors. The content emphasizes the importance of understanding error estimates in numerical methods, especially when analytical solutions are not available.

Uploaded by

youssefsamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ENGR 3202

Engineering Analysis and


Computation
Week 2

MATLAB,
Approximation and
Error, Roots of
Equation
Abdelaziz Khlaifat
Professor & Chair
Petroleum & Energy Engineering Department
SSE, AUC
Email: [Link]@[Link]
Room: SSE 1006

11
ENGR 3202
Content (Topics / LOs)

• Programming using MATLAB (2.5, Appendix B)


• Approximation and Error (A&E, Ch. 3):
– Significant figures (3.1)
– A&E: Accuracy and precision (3.2)
– A&E: Error definitions (3.3, Note1)
• Roots of Equations
– Motivation (PT2.1 (p.113))
– Mathematical background (PT2.2 (p. 115)

2
ENGR 3202
2.5. MATLAB

Textbook:
• Section 2.5 and Appendix B
Handouts:
• General Programming Lab lecture notes on Canvas.

[Link]

3
ENGR 3202
3. APPROXIMATIONS AND ERROR

Analytical and numerical methods


 Analytical methods – yield exact analytical solution
 Numerical techniques - yield approximate solution that is close to the
exact analytical solution, there are a discrepancy, or error, because
the numerical method involved an approximation.
 If analytical solution is available then the error (analytical value –
approximate value) can be computed exactly.
 For many applied engineering problems, we cannot obtain analytical
solutions. Therefore, we cannot compute exactly the errors associated
with our numerical methods. In these cases, we must settle for
approximations or estimates of the errors.

4
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures
Whenever we employ a number in a computation, we must have
assurance that it can be used with confidence.
Fig. 3.1 depicts a car speedometer and odometer

 Visual inspection of the


speedometer indicates
that the car is traveling
between 48 and 49 km/h.
 Because the indicator is higher
than the midpoint between the
markers on the gauge, we
can
say with assurance that
the car is traveling at
approximately 49 km/h.

5
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures
 We have confidence in this result because two or more reasonable
individuals reading this gauge would arrive at the same conclusion.

 However, let us say that we


insist that the speed be
estimated to one decimal
place. For this case, one
person might say 48.8,
whereas another might say
48.9 km/h.
 Therefore, because of the
limits of this instrument, only
the first two digits can be
used with confidence.
 Estimates of the third digit
(or higher) must be viewed
as approximations. 6
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures

The odometer provides up to 6 certain digits.

 One can conclude that


the car has traveled
slightly less than
87,324.5 km during its
lifetime.
 In this case, the seventh
digit (and higher) is
uncertain.

7
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures
 Significant figure/digit designates the reliability of a numerical value.
 The significant digits/figures of a number are those that can be used
with confidence. They correspond to the number of certain digits
plus one estimated digit.
 The speedometer and the odometer yield readings of three and seven
significant figures, respectively.
 For the speedometer, the two certain digits are 48. If we set the
estimated digit at one-half, then the speedometer reading would
consist of the three significant figures: 48.5.
 In a similar fashion, the odometer would yield a seven-significant-
figure reading of 87,324.45.

8
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures
Cases that can lead to confusion: Zeros
 For example, zeros are not always significant figures because they
may be necessary just to locate a decimal point.
 The numbers 0.00001845, 0.0001845, and 0.001845 all have four
significant figures.
 Likewise, when trailing zeros are used in large numbers, it is not clear
how many, if any, of the zeros are significant.
 For example, at face value the number 45,300 may have three,
four, or five significant digits, depending on whether the zeros are
known with confidence.
 Such uncertainty can be resolved by using scientific notation,
where 4.53x104, 4.530x104, 4.5300x104 designate that the number
is known to three, four, and five significant figures, respectively.
9
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures

10
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.1. Significant Figures
Two important implications of the concept of significant figures in this
course:

 Numerical methods yield  Although quantities such as 𝜋, 𝑒, 𝑜𝑟 7


approximate results. represent specific quantities, they
cannot be expressed exactly by a limited
 We must, therefore, develop criteria
number of digits.
to specify how confident we are in
our approximate result.  For example,

 One way to do this is in terms of 𝜋= 3.141592653589793238462643. . .


significant figures.  Because computers retain only a finite
 For example, number of significant figures, such
numbers can never be represented
we might decide that our exactly.
approximation is acceptable if it is
 The omission of the remaining
correct to four significant figures.
significant figures is called round-off 11
ENGR 3202
error.
3. APPROXIMATIONS AND ERROR
3.2. Accuracy and Precision
The errors associated with both calculations and measurements can be
characterized with regard to their accuracy and precision.

 Accuracy refers to
how closely a
computed or
measured value
agrees with the true
value.
 Precision refers to
how closely
individual computed
or measured values
agree with each
other.
12
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions
 Numerical errors arise from the use of approximations to represent
exact mathematical operations and quantities. These include:
 Truncation errors – which result when approximations are used to represent
exact mathematical procedures, and
 Round-off errors – which result when numbers having limited significant
figures are used to represent exact numbers.
 For both errors, the relationship between the exact/true and the
approximation results can be formulated as:

T𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 = 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 + 𝑒𝑟𝑟𝑜𝑟 (3.1)

 Rearrange Eq (3.1) and use Et to designate the exact value of the


error. The subscript t is included to designate that this is the “true” error, then:

𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒𝑠 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (3.2)


13
ENGR 3202 Back to slide 16
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions
 A shortcoming of the true error (Et) is that it does not account of the
order of magnitude of the value under examination.
 For example, an error of a centimeter is much more significant if we
are measuring a rivet (bolt) rather than a bridge.
 One way to account for the magnitudes of the quantities being
evaluated is to normalize the error to the true value, as follows:
𝑡𝑟𝑢𝑒 𝑒𝑟𝑟𝑜𝑟 (𝐸𝑡 )
T𝑟𝑢𝑒 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛𝑎𝑙 𝑟𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝑒𝑟𝑟𝑜𝑟 =
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒

 The relative error can also be multiplied by 100 % to express it as:

𝑡𝑟𝑢𝑒 𝑒𝑟𝑟𝑜𝑟 (𝐸𝑡 )


𝜀𝑡 = 100% (3.3)
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒

where 𝜀𝑡 labels the true percent relative error.


14
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions

Although both measurements


have an error of 1 cm, the
relative error for the rivet is
much greater.
15
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions
• True value used in Example 3.1, is rarely available in actual situation.
• For numerical methods: the true value will be known only when we
deal with functions that can be solved analytically.
• In real-world applications (complex systems), we will clearly not know
the true answer a priori.
• For real-world applications cases - an alternative is to normalize the
error using the best available estimate of the true value, that is, to the
approximation itself, as in:

𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
𝜀𝑎 = 100% (3.4)
𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛

where the subscript 𝑎 signifies that the error is normalized to an approximate value

16
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions
 For real-world applications, Eq. (3.2) cannot be used to calculate the
error term for Eq. (3.4).
 Numerical methods challenge - to determine error estimates in the
absence of knowledge regarding the true value. Thus, percent
relative error is determined according to:

𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛−𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛


𝜀𝑎 = 100% (3.5)
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛

 What is the sign of the error?


 Can the error be +tive?
 Can the error be –tive?

17
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions
 The signs of Eqs. (3.2) through (3.5) may be either positive (+) or
negative (-) which might lead to positive or negative error value.
 Often, when performing computations, we are interested in whether
the percent absolute value is lower than a pre-specified percent
tolerance (𝜀𝑠 ) . Therefore, it is often useful to employ the absolute
value of Eqs. (3.2) through (3.5). For such cases, the computation is
repeated until:

𝜀𝑎 = 𝜀𝑠 (3.6)

 It is also convenient to relate these errors to the number of significant figures (n)
in the approximation. It can be shown (Scarborough, 1966) that if the following
criterion is met, we can be assured that the result is correct to at least n significant
figures.
𝜀𝑠 = 0.5 𝑥 102−𝑛 %
(3.7)
18
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions

19
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions

20
ENGR 3202
3. APPROXIMATIONS AND ERROR
3.3. Error Definitions

<
Computation is terminated
21
ENGR 3202
Questions

THANK You 

ENGR 3202 22

You might also like