Lecture No 12
Lecture No 12
1
Numerical Analysis
Dr. Abdul Haleem Hamid
Errors in Numerical Calculations
• Error: Let X be an exact number/ solution of any problem and 𝛼
of 𝜶.
Error =E = X – 𝛼
• Note:
• Exact Numbers – Numbers that have their exact quantity, means
their value isn’t going to change. For example- 3, 2, 5, 7, 22/7,
4/5, or √2 etc.
• Approximate Numbers – These numbers are represented in
decimal numbers. They have certain degrees of accuracy. Like
the value of π is 3.1416 if we want a more precise value, we can
write 3.14159265, but we can’t write the exact value of π. These
digits that we use in any approximate value, or in other ways
digits that represent the numbers are called Significant Digits.
Type of error
• ABSOLUTE ERROR
The absolute error 𝐸𝐴 of an approximate number 𝛼 is the absolute
value of the difference between the corresponding exact number x and
the number𝛼.
𝐸𝐸 𝐴 = |𝑋𝐸 − 𝑋𝐴|
RELATIVE ERROR
The relative error 𝐸𝑅 of an approximate number 𝛼is the ratio of the
absolute error 𝐸𝐴 of the number to the modulus of the
corresponding exact number x. From the definition we have
𝐸𝑅 = 𝐸𝐴 / 𝑋𝐴 =|𝑋𝐸 − 𝑋𝐴|/ 𝑋𝐴
Percentage Error.
It is the ratio of the Absolute Error to the true value multiplied by 100,
it can also be defined as Relative Error multiplied by 100.
The errors in mathematical solution problems are
of five types.
• Errors involved in the statement of the problems
• Errors stemming from the presence of infinite processes in
mathematical analysis
• Errors due to numerical parameters whose value can only be
determined approximately
• Errors associated with the system of numeration
• Errors due to operations involving approximate numbers
Errors in Computation
Round-off Errors
These errors occur because computers have limited precision and
cannot represent every real number exactly. When performing
calculations, especially with floating-point numbers, rounding
occurs, and the results can be slightly different from the
mathematically exact result.
Cause: Limited number of digits used in representation of
numbers (e.g., floating-point numbers) and approximations during
arithmetic operations.
Example: The number 1/3 can't be exactly represented in binary
form, so it's approximated.
Note: Use higher precision arithmetic (double precision, for
instance) or algorithms that are designed to reduce the impact of
rounding errors.
Errors in Computation
Truncation Errors
These errors occur when a mathematical procedure is
approximated by truncating an infinite process (like a series or
an integral) to a finite number of terms or steps.
Cause: Using a finite number of terms to represent an infinite
series or approximating continuous operations.
Example: Truncating the infinite series for the sine function (e.g.,
using only the first few terms in the Taylor series
approximation).
Note: Use more terms in series expansions or more steps in
numerical integration to reduce the error.
• Propagation of Errors
This type of error arises when small errors from individual
calculations accumulate and affect the final result, especially
when many operations are involved.
Cause: Error in intermediate steps that amplify in subsequent
steps.
Example: If each measurement or computation has a small error,
those errors can accumulate as the calculation proceeds, leading
to larger deviations from the true result.
Note: Be cautious with the order of operations, and try to use
algorithms that reduce the cumulative error, such as those
designed for stability in numerical methods (e.g., Kahan
summation)
Example 1:
The height of a tower was estimated to be 50 m
Using Theodolite But the height was 45. Calculate the absolute
error, relative error and percentage error involved in the
Estimated height = 𝑋𝐴 = 50 m
Absolute error = 𝐸𝐴 = | 𝑋𝐸 − 𝑋𝐴 | = |50 −45|= 5 m
Relative Error = 𝐸𝑅 = 𝐸𝐴 = 5 = 0.111
𝑋
• Percentage error = 𝐸𝑅 × 100 = 11.1 %
45
Example 2
• Example 2: Finding the Best Approximation
• Problem: Given approximate values of 1/3 as 0.30, 0.33, and
0.34, find out the best approximation.
• Solution: True Value (X): 1/3 ≈ 0.333333
• Absolute Errors:
• |0.333333 – 0.30| = 0.033333
• |0.333333 – 0.33| = 0.003333
• |0.333333 – 0.34| = 0.006667
• The value 0.33 has the smallest absolute error, so it is the best
approximation.
Example 3:
• Problem: Compute the difference between √5.35 and √4.35.
• Solution:
• √5.35 ≈ 2.31300
• √4.35 ≈ 2.08566
• Difference: 2.31300 – 2.08566 = 0.22734
Example 4: Comparing Errors in
Numerical Approximations
• Problem: Given the true value of a physical quantity as 8.76 and approximate values as
8.70, 8.80, and 8.75, find and compare the absolute, relative, and percentage errors.
• Solution:
• True Value (X): 8.76
• Approximate Values:
• For 8.70:
• Absolute Error = |8.76 – 8.70| = 0.06
• Relative Error = 0.06 / 8.76 = 0.00685
• Percentage Error = 0.00685 × 100% = 0.685%
• For 8.80:
• Absolute Error = |8.76 – 8.80| = 0.04
• Relative Error = 0.04 / 8.76 = 0.00456
• Percentage Error = 0.00456 × 100% = 0.456%
• For 8.75:
• Absolute Error = |8.76 – 8.75| = 0.01
• Relative Error = 0.01 / 8.76 = 0.00114
• Percentage Error = 0.00114 × 100% = 0.114%
• Best Approximation: 8.75, having the smallest errors in all cases.
• Example 5: Significant Digits in Scientific Notation
• Problem: Determine the number of significant digits in the
following scientific notations:
• 2.345 × 10^7
• 8.7456 × 10^4
• 5.4 × 10^6
• Solution:
• 2.345 × 10^7: 4 significant digits
• 8.7456 × 10^4: 5 significant digits
• 5.4 × 10^6: 2 significant digits