Lecture-1 - Introduction and Errors
Lecture-1 - Introduction and Errors
Analysis and numerical analysis are two related but distinct fields within mathematics. Here's an
explanation of the difference between the two:
Analysis:
1. Analysis, also known as mathematical analysis, is a branch of mathematics that deals with the
rigorous study of concepts such as limits, continuity, derivatives, integrals, sequences, and series.
2. It focuses on proving theorems and establishing mathematical foundations.
3. The analysis seeks to understand the properties and behavior of mathematical objects using logical
reasoning and abstract concepts. It is a broad field that encompasses various subfields like real
analysis, complex analysis, functional analysis, and harmonic analysis.
Numerical Analysis:
1. Numerical analysis, on the other hand, is a branch of mathematics that focuses on developing
numerical algorithms and methods to solve mathematical problems, particularly those that are
difficult or impossible to solve analytically.
2. It involves the study of algorithms, approximation techniques, and computational methods to obtain
numerical solutions to mathematical problems.
3. Numerical analysis utilizes computational tools and techniques to perform calculations,
simulations, and optimization in various scientific, engineering, and practical applications. It
involves topics like interpolation, numerical integration, root-finding methods, numerical linear
algebra, and differential equations.
In summary, analysis is concerned with the theoretical study of mathematical concepts and the development
of rigorous proofs, while numerical analysis is focused on the practical aspects of solving mathematical
problems using numerical methods and algorithms on computers. The analysis provides the theoretical
foundation upon which numerical analysis builds its computational techniques and algorithms.
Application of Numerical Methods in Computer Science
Numerical methods play a crucial role in various areas of computer science. Here are some applications of
numerical methods in computer science:
1. Numerical Analysis: Numerical analysis is a field of study that focuses on developing algorithms and
numerical techniques to solve mathematical problems. It involves methods such as interpolation,
approximation, numerical integration, solving differential equations, and finding roots of equations. These
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
techniques are extensively used in computer science for solving complex mathematical problems and
optimizing algorithms.
2. Simulation and Modeling: Numerical methods are widely used in computer simulations and modeling.
They allow researchers and scientists to simulate and predict the behavior of complex systems, such as
physical phenomena, weather patterns, fluid dynamics, and electrical circuits. Numerical methods enable
the approximation of continuous systems and the computation of their behavior over time.
3. Computer Graphics and Image Processing: In computer graphics and image processing, numerical
methods are used for rendering, geometric transformations, ray tracing, image filtering, and compression.
Techniques like interpolation, approximation, and numerical optimization algorithms are applied to create
visually appealing and realistic graphics, as well as process and manipulate images.
4. Machine Learning and Data Analysis: Numerical methods are an integral part of machine learning and
data analysis algorithms. Optimization methods like gradient descent are used to train machine learning
models and find optimal parameters. Techniques such as clustering, regression, and classification rely on
numerical methods to process and analyze large datasets efficiently.
5. Cryptography: Numerical methods are employed in cryptographic algorithms for secure
communication and data encryption. Prime number generation, modular arithmetic, and elliptic curve
cryptography involve mathematical computations that heavily rely on numerical methods.
6. Computational Geometry: Numerical methods are applied in computational geometry algorithms for
solving geometric problems, such as point location, convex hulls, intersection detection, and proximity
queries. Efficient algorithms based on numerical techniques help in solving complex geometric problems
encountered in computer vision, robotics, and computer-aided design.
7. Network Analysis and Optimization: Numerical methods are utilized in network analysis and
optimization problems, including routing algorithms, network flow analysis, load balancing, and network
design. These methods help in optimizing network performance, reducing congestion, and improving
scalability and efficiency.
Overall, numerical methods are fundamental tools in computer science, enabling the efficient and accurate
solution of mathematical problems, simulation of complex systems, and optimization of algorithms across
various domains.
Errors:
Real-world problems, in which an existing or proposed physical situation is modeled by a mathematical
equation, will nearly always have coefficients that are imperfectly known. The reason is that the problems
often depend on measurements of doubtful accuracy. Further, the model itself may not reflect the behavior
of the situation perfectly. We can do nothing to overcome such errors by any choice of method, but we need
to be aware of such uncertainties; in particular, we may need to perform tests to see how sensitive the results
are to changes in the input information. Because the reason for performing the computation is to reach some
decision with validity in the real world, sensitivity analysis is of extreme importance. As Hamming says,
"The purpose of computing is insight, not numbers."
Error in solving an engineering or science problem can arise due to several factors. First, the error may be
in the modeling technique. A mathematical model may be based on using assumptions that are not
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
acceptable. For example, there are two kinds of numbers such as exact and approximate numbers, such the
2 3
exact numbers are 1, 2, 5, … … … . . 5 , 2 , … … … . . 𝜋, … . 𝑒 and approximate numbers are representations of
exact numbers to a certain degree of accuracy. Thus, 3.1416 is an approximate number of 𝜋 and 3.14159265
is another approximate number of 𝜋. Second, errors may arise from mistakes in the programs themselves
or in the measurement of physical quantities. But, in applications of numerical methods itself, hear we focus
on these types of errors,
1. Absolute error
2. Relative error
3. Percentage error
4. Round off error
5. Truncation error.
Absolute error
The absolute error of a quantity is the absolute value of the difference between the exact value and the
approximate value. It is denoted by 𝐸𝐴 . If the exact value is 𝑋 and the approximate value is 𝑥, the absolute
error is defined by,
𝐸𝐴 = |𝑋 − 𝑥|
Relative error
The relative error of a quantity is the ratio of its absolute error to its exact value. It is denoted by 𝐸𝑅 , that
is
𝐸𝐴
𝐸𝑅 =
𝑋
Percentage error
The percentage error of a quantity is 100 times its relative error. It is denoted by 𝐸𝑃 , that is
𝐸𝑃 = 100𝐸𝑅
Problem-01: If an approximate value of 𝜋 is 3.1428571 and let exact value is 3.1415926. Find the
absolute, relative and percentage errors.
Solution: We have, exact value is 𝑥 = 3.1415926 and approximate value is 𝑋 = 3.1428571
The absolute error is, 𝐸𝐴 = |𝑋 − 𝑥| = |3.1428571 − 3.1415926 | = |−0.0012645 | = 0.0012645
𝐸𝐴 0.0012645
The relative error is, 𝐸𝑅 = = = 0.000402
𝑋 3.1428571
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
Round off Error
When a calculator or digital computer is used to perform numerical calculations, an unavoidable error,
called round-off error, must be considered. A round-off error, also called rounding error, is the difference
between the calculated approximation of a number and its exact mathematical value due to rounding. For
1
example, a number like 3 may be represented as 0.33333 on a PC. Then the round off error in this case is
1
− 0.33333 = 0.0000033. Then there are other numbers that cannot be represented exactly. For example,
3
𝜋 and √2 are numbers that need to be approximated in computer calculations.
Problem-02: Find the absolute, relative and percentage errors of the number 8.6 if both of its digits are
correct (i.e, this number rounded to one decimal place).
Solution: The given number is 8.6
Since both digits are correct so, 𝑁 = 1
1 1
The absolute error is, 𝐸𝐴 = 2 (10−𝑁 ) = 2 (10−1 ) = 0.05 (i.e, exact value 𝑋 = 8.6 )
𝐸𝐴 0.05
The relative error is, 𝐸𝑅 = 𝑋
= 8.6
= 0.0058
𝑥 𝑥 2 3𝑥 3
𝑦 =1+ + + + ⋯…
2 2 8
0.1 (0.1)2 (0.1)3
𝑦(0.1) = 1 + + + + ⋯ … … … … 𝑟𝑒𝑠𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑠𝑒𝑟𝑖𝑒𝑠 𝑡𝑎𝑛𝑠 𝑡𝑜 0
2 2 8
𝑦(0.1) ≈ 1.055375 ≈ 1.0554
Here, two errors are occurred one is truncation error and another one is round off error. If we increase the
power of 0.1 in that series it will be approximately zero. So, we discarded those values from our series.
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
General Formula of Error
Let 𝑢 = 𝑓(𝑥, 𝑦, 𝑧) be the function of 3 variables
𝑑𝑓 𝑑𝑓 𝑑𝑓
∴ ∆𝑢 = 𝑑𝑥 ∆𝑥 + 𝑑𝑦 ∆𝑦 + 𝑑𝑧 ∆𝑧 [Here, we used partial differentiation and total differential coefficient]
𝑑𝑢 5𝑦 2 𝑑𝑢 10𝑥𝑦 𝑑𝑢 15𝑥𝑦 2
= 3 ; = 3 ; =−
𝑑𝑥 𝑧 𝑑𝑦 𝑧 𝑑𝑧 𝑧4
We know,
𝑑𝑢 𝑑𝑢 𝑑𝑢 5𝑦 2 10𝑥𝑦 15𝑥𝑦 2
∆𝑢 = ∆𝑥 + ∆𝑦 + ∆𝑧 = 3 ∆𝑥 + 3 ∆𝑦 − ∆𝑧
𝑑𝑥 𝑑𝑦 𝑑𝑧 𝑧 𝑧 𝑧4
5𝑦 2 10𝑥𝑦 15𝑥𝑦 2
(∆𝑢)𝑚𝑎𝑥 = | ∆𝑥| + | ∆𝑦| + |− ∆𝑧|
𝑧3 𝑧3 𝑧4
5(1)(1)2
𝑎𝑡 𝑥 = 𝑦 = 𝑧 = 1, 𝑢 = =5
(1)3
(∆𝑢)𝑚𝑎𝑥 0.03
(𝐸𝑅 )𝑚𝑎𝑥 = = = 0.006
𝑢 5
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
Difference Between the Round Off Error and the Truncation Error
Round off error is the error caused by approximate representation of numbers. When we talk about round
200
off error, it is the error between the number and its representation. For example, would be represented
3
as 66.6667 in a six significant digit computer that rounds off the last digit. The last digit has been rounded
200 200
up from 6 to a 7. The difference between 3 𝑎𝑛𝑑 66.6667, that is, 3 − 66.6667 is the round off error.
Truncation error is error caused by truncating a mathematical procedure. So, let us get this straight – round
off error is caused by representing numbers approximately and truncation error is caused by approximating
mathematical procedures.
Significant Digits
Significant digits are certain digits that have significance or meaning and give more precise details about
the value of the number. If I offered you $2,000, the 2 in 2000 is significant because it tells you exactly
how many thousands.
Again, let's say two people ran a race. Runner 1 took 30.01 seconds, and runner 2 took 30.02 seconds.
Who would win the race? Obviously, runner 1 because he took less time. All those numbers are significant
because we need them all to tell us exactly who won the race. So, we have some rules to identify the
significant numbers,
Rule 1: Every non-zero digit is significant
• 456 has 3 significant digits
• 68.29 has 4 significant digits
Rule 2: Zeros between non-zero digits are always significant
• 5,609 has 4 significant digits.
• 700.0879 has 7 significant digits.
Rule 3: Zeros before non-zero digits are never significant
• 0.067 has 2 significant digits
• 0.000008 has 1 significant digit
Rule 4: Zeros behind non-zero digits are sometimes significant
• 12.2300 has six significant figures: 1, 2, 2, 3, 0 and 0.
• 0.000122300 still has only six significant figures (the zeros before the 1 are not significant).
• 120.00 has five significant figures since it has three trailing zeros.
Note: If the digit immediately to the right of the last significant figure is greater than 5 or is a 5 followed
by other non-zero digits, add 1 to the last significant figure. For example, 1.2459 as the result of a
calculation or measurement that only allows for 3 significant figures should be written 1.25.
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181
Problem-04: Evaluate the 𝑆𝑢𝑚, 𝑆 = √2 + √3 + √5 to 4 significant digits and also find its absolute,
relative and percentage errors.
Solution:
More Problems:
1. Define percentage error, absolute error with example.
2. Evaluate the sum 𝑆 = √3 + √5 + √7 + √11 to significant digits and find its percentage error,
absolute error, relative error?
3. Find the absolute, relative and percentage errors of the number 8.2154356 if 4 significant digits are
correct.
4. Evaluate the sum 𝑆 = √11 + √21 + √31 to 5 significant digits and find its 𝐸𝐴 , 𝐸𝑃 , 𝐸𝑅 ?
5. Find the absolute, relative and percentage errors of the number 0.3576 if 2 significant digits are
correct.
Shahadat Hossain
Senior Lecturer, Department of CSE
Daffodil International University
shahadat.cse@diu.edu.bd, 01624823181