Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lecture.1 - Numerical (Autosaved)

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

‫‪Numerical‬‬

‫‪analysis‬‬

‫د‪ .‬على رفاعى عبدالاله محمد‬


‫كلية الهندسة بقنا جامعة األزهر‬

‫‪10/23/24‬‬ ‫‪1‬‬
Introduction to numerical analysis
 Numerical analysis is a branch of mathematics that deals with the development and analysis of algorithms
for solving mathematical problems. These algorithms are designed to approximate solutions to problems that
may be difficult or impossible to solve exactly.
 A numerical method is an approximate computer method for solving a mathematical problem
which often has no analytical solution.
 The branch of mathematics that deals with the development and use of numerical methods for
solving problems.
 Numerical analysts are very interested in the effects of using finite precision computer arithmetic.
This is especially important in numerical linear algebra, as large problems contain many rounding
errors.
 Numerical analysts are generally interested in measuring the efficiency (or “cost”) of an algorithm.
 It is widely used for forecasting and predicting in the field of machine learning. Solving differential and
integral equations:
 Most mathematical models (particularly in engineering) are based on the solutions obtained by partial differential
equations, ordinary differential equations and integral equations

2 http://numericalmethods.eng.usf.edu
Key Concepts in Numerical Analysis
•Approximation: Numerical methods often involve approximating
a solution to a problem with a simpler, more manageable one.
•Error: The difference between the exact solution and the
approximate solution is known as the error.
•Algorithm: A step-by-step procedure for solving a problem.
•Convergence: A numerical method is said to converge if the
approximate solutions get closer and closer to the exact solution
as the number of iterations or steps increases.
•Stability: A numerical method is said to be stable if small
changes in the input data do not lead to large changes in the
output.

3 http://numericalmethods.eng.usf.edu
Common Numerical Methods
•Root-finding: Methods for finding the roots of a function (e.g., Newton-
Raphson method, bisection method).
•Interpolation: Methods for approximating a function between known
data points (e.g., Lagrange interpolation, spline interpolation).
•Numerical differentiation: Methods for approximating the derivative
of a function (e.g., finite difference method).
•Numerical integration: Methods for approximating the definite
integral of a function (e.g., trapezoidal rule, Simpson's rule).
•Linear algebra: Methods for solving systems of linear equations and
finding eigenvalues and eigenvectors.
•Optimization: Methods for finding the minimum or maximum of a
function (e.g., gradient descent, simplex method).
•Differential equations: Methods for solving ordinary and partial
differential equations (e.g., finite difference methods, finite element
methods).

4 http://numericalmethods.eng.usf.edu
Errors Definition
 Numerical error arise from the use of approximation to represent
exact mathematical operations and quantities
 Truncation Error - approximation of mathematical procedures
 Round-off error - approximation of exact numbers
 The relation between exact, or true and the approximate is given
as:
True value = Approximation + error.
True error = true value - approximation
 Rounding error is an error that occurs when a number is represented with fewer digits
than required to fully capture its exact numerical value.
 Truncation error is an error that occurs when limiting the accuracy and/or running time
of a program that requires an unrealistic amount of time (possibly infinite) to obtain an
accurate, true answer.
Et = true error = exact value of the error

5 http://numericalmethods.eng.usf.edu
 One way to account for the magnitudes of the quantities being evaluated is
to normalized the error to the true value by true fractional relative error:

True Fractional Relative Error = Error/True value

True percent relative error, Et :

Et = (true error/ true value) x 100%

6 http://numericalmethods.eng.usf.edu
Why measure errors?
1) To determine the accuracy of numerical
results.
2) To develop stopping criteria for iterative
algorithms.

7 http://numericalmethods.eng.usf.edu
True Error
 Defined as the difference between the true value in a
calculation and the approximate value found using a
numerical method etc.

True Error = True Value – Approximate Value

8 http://numericalmethods.eng.usf.edu
Example of True Error
True error is the difference between the actual, or true, value of a quantity and its
approximation. In other words, it's the error that remains after all other sources of error
have been accounted for.
Example: Measuring the Height of a Tree
•True value: The actual height of the tree, as measured by a highly accurate laser device.
•Approximate value: The height measured using a tape measure and a method of
estimating the height of the inaccessible top.
If the laser device measures the tree to be 30 meters tall, but the tape measure method
yields a result of 28 meters, then the true error is 30 meters - 28 meters = 2 meters.
Key points to remember:
•True error is often unknown, as it requires knowing the exact, true value.
•It is a theoretical concept used to evaluate the accuracy of measurements or calculations.
•Other types of errors, such as systematic errors or random errors, can contribute to the
overall error.
Another example:
•True value: The exact value of pi (3.14159...).
•Approximate value: A rounded value of pi (3.14).
•True error: The difference between the true value and the approximate value (0.00159...).

9 http://numericalmethods.eng.usf.edu
Example—True Error
The f (x) of a f (x) can be
derivative,
approximated by the function
equation,
f ( x  h)  f ( x)
f ' ( x) 
h

If f ( x) 7e an h 0.3
0.5 x

a) Find dthe approximate f ' ( 2)


value
b) True ofvalue f ' (2)
of
c) True error for part
(a)

10 http://numericalmethods.eng.usf.edu
Example (cont.)
Solution:
a) For x 2 and h 0.3
f ( 2  0.3)  f ( 2)
f ' ( 2) 
0 .3
f (2.3)  f (2)

0.3
7 e 0 .5 ( 2 .3 )  7 e 0 .5 ( 2 )

0.3
22.107  19.028
 10.263
0.3

11 http://numericalmethods.eng.usf.edu
Example (cont.)
Solution
: b) The exact value f ' ( 2) can be found by
of knowledge of differential
our usingcalculus.
f ( x )  7 e 0.5 x
f ' ( x ) 7 0.5 e 0.5 x
3.5e 0.5 x
So the true value f ' ( 2) is
0.5( 2 )
of f ' ( 2 )  3.5e
9.5140
True error is calculated as
Et  True Value – Approximate
9.Value
5140  10.263  0.722

12 http://numericalmethods.eng.usf.edu
Relative True Error
 Defined as the ratio between the
true error, and the true value.
True Error
Relative True Error(t ) =
True Value
Relative True Error = (|Approximate Value - True Value|) / True
Value

13 http://numericalmethods.eng.usf.edu
Example—Relative True Error
Following from the previous example for true
error,
find the relative true error f ( x) 7e 0.5 x at f ' (2)
for
wit h 0.3
h From the previous example,
Et  0.722
Relative True Error is defined
as t  True Error
True Value
 0.722
  0.075888
9.5140
as a percentage,
t  0.075888 100%  7.5888%

14 http://numericalmethods.eng.usf.edu
Relative true error is a measure of the accuracy of a
measurement or approximation compared to the true value. It's
expressed as a ratio of the absolute error to the true value.
Formula:
Relative True Error = (|Approximate Value - True Value|) / True
Value
Example:
Let's say you're measuring the length of a table. The true length
is 2.5 meters, but your measurement comes out as 2.48 meters.
•Absolute Error: |2.48 - 2.5| = 0.02 meters
•Relative True Error: (0.02 / 2.5) = 0.008 = 0.8%
Interpretation: The relative true error of 0.8% indicates that
your measurement is 0.8% off from the true value.

15 http://numericalmethods.eng.usf.edu
Approximate Error
 What can be done if true values are not known
or are very difficult to obtain?
 Approximate error is defined as the difference
between the present approximation and the
previous approximation.

Approximate E a ) = Present Approximation – Previous


Error ( Approximation

16 http://numericalmethods.eng.usf.edu
Example—Approximate Error
For f ( x) 7e 0.5 x at x 2 find the
a) f (2) usin h 0.3 following,
b) f (2) gusin h 0.15
c) approximateg error for the f (2) for part
value of
Solution: b)
a) x 2 and h 0.3
For f ' ( x )  f ( x  h )  f ( x )
h
f ( 2  0.3)  f ( 2)
f ' ( 2) 
0 .3

17 http://numericalmethods.eng.usf.edu
Example (cont.)
Solution: (cont.)
f (2.3)  f (2)

0.3
7 e 0 .5 ( 2 .3 )  7 e 0 .5 ( 2 )

0.3
22.107  19.028
 10.263
0.3
b) x 2 and h 0.15
For f ' (2) 
f (2  0.15)  f (2)
0.15
f (2.15)  f (2)

0.15

18 http://numericalmethods.eng.usf.edu
Example (cont.)
Solution: (cont.)
7e 0.5( 2.15)  7e 0.5( 2 )

0.15
20.50  19.028
 9.8800
0.15

c) So the approximate E a is
error,
Ea Present Approximation – Previous
9Approximation
.8800  10.263
 0.38300

19 http://numericalmethods.eng.usf.edu
Relative Approximate Error
 Defined as the ratio between the
approximate error and the present
approximation.
Approximate Error
Relative Approximate a) =
Error ( Present Approximation

20 http://numericalmethods.eng.usf.edu
Example—Relative Approximate Error
For f ( x) 7e 0.5 x
at x 2 , find the relative
error using values approximate
h 0.3 and h 0.15
from
Solution:
From Example 3, the approximate f (2) 10.263
value
usin hof
0.3 and f (2) 9.8800 usin h 0.15
g Ea  Present Approximationg– Previous
9Approximation
.8800  10.263
 0.38300

21 http://numericalmethods.eng.usf.edu
Example (cont.)
Solution:
(cont.) Approximate Error
a 
Present Approximation
 0.38300
  0.038765
9.8800
as a
percentage,
a  0.038765 100%  3.8765%

Absolute relative approximate errors may also


need to be calculated,
a |  0.038765 | 0.038765 or 3.8765 %

22 http://numericalmethods.eng.usf.edu
How is Absolute Relative Error used as a stopping
criterion?
If |a | s wher s is a pre-specified tolerance,
no further e iterations
then are necessary, and the
process is stopped.

If at least m significant digits are required


to be correct in the final answer, then
|a |0.5 10 2 m %

23 http://numericalmethods.eng.usf.edu
Table of Values
0.5 x
For f ( x) 7e at x 2 with varying step h
size,
h f (2) a m
0.3 10.263 N/A 0

0.15 9.8800 3.877% 1

0.10 9.7558 1.273% 1

0.01 9.5378 2.285% 1

0.001 9.5164 0.2249% 2

24 http://numericalmethods.eng.usf.edu
Example 2. Determine Et , and Ea when approximating the
derivative of f (x) = −x2 + 5x at x = 2, using the approximation
formula

with h = 0.1. f’(x)=(f(x + h) − f (x))/h

Example 2 Solution. f′(x) = −2x + 5, and so f′(2) = 1. On the other


hand,

f′(x) = ((−(2.1)2 + 5(2.1)) − (−(2)2 + 5(2)))/0.1 = 0.9.

Therefore, Et = 1 − 0.9 = 0.1, and Ea = 0.1/1 = 0.1.


Note: sometimes we prefer to discuss the percentage relative error
25
which is defined as 100 × Ea. http://numericalmethods.eng.usf.edu
26 http://numericalmethods.eng.usf.edu
THE END

You might also like