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

Week 2 Numbers and Errors - Spring 2022-23 INS 202E

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

INS 202E Numerical Methods in

Civil Engineering

2022-23 Spring

Atila Sezen, Ph.D.


Research Associate
Civil Engineering Department
Geotechnical Laboratories
E-mail : sezenati@itu.edu.tr
Phone: +90 212 285 37 88
Numbers and Errors

God gives the nuts, but he/she does not crack them.
Franz Kafka

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


NUMERICAL METHODS are mathematical techniques used for solving
mathematical problems that can not be solved OR are difficult to solve analytically.

An analytical solution >> EXACT ANSWER in the form of a mathematical expression

A numerical solution >> APPROXIMATE NUMERICAL VALUE for the solution

There is a discrepancy or error between the analytical and numerical solutions, i.e.
Error = True Value – Approximate Value

Understanding the errors and error analysis is important for the effective use of
numerical methods!

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Errors in numerical solutions

So the question is: How accurate the data and the results are?
Main sources of error in modeling of a physical problem:
Errors not directly connected with the numerical methods
themselves:
• Due to mathematical modeling of a physical problem.
• Assumptions, simplications, linearization of non-linear processes,

These include blunders, measurement, formulation or model errors


Inaccurate measurement of data, low precision in the measuring
devices, miscopying of data etc.,
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Errors in numerical solutions
Numerical Methods can be very accurate but in general are NOT exact.
So the question is: How accurate the data and the results are?
Main sources of error in modeling of a physical problem:
Errors not directly connected with the numerical methods themselves
: Inaccurate measurement of data, low precision in the measuring devices,
miscopying of data etc.,
Round-off errors result when numbers having limited significant figures
are used to represent exact numbers. It can also be said that this error is
due to finite precision of the numbers that can be represented in a
computer.
Truncation errors result when approximations are used to represent exact
mathematical procedures.
Total error is the difference between the true (exact) solution and the approximate
solution.
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Errors in numerical solutions
Round-off Errors
• In general a number can be shortened by:
Rounding-off the last digit that is stored is rounded.
round-to-nearest
Chopping off (discarding the extra digit)
The digits in the mantissa beyond the length that can be stored are
left out.
round-by-chop
2 2
= 0,6667 = 0,6666
3 3
The number is chopped off.
The number is rounded to the nearest.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Round-off errors and numbers in computers

• Originate from the fact that computers retain only a fixed


number of significant figures during a calculation.
• Numbers such as π, e or 7 can not be represented exactly by
computers.

• Computers use a base-2 (binary) representation and


cannot precisely represent certain base-10 numbers.

• Round-off errors occur because of the way that digital


computers store numbers and execute numerical
operations.
Round-to-nearest rules

From http://www.flinders.edu.au
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Rounding-off rules

Answer: 6.76

From http://www.flinders.edu.au
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Errors in numerical solutions

Bakioğlu (2011)
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Truncation error
Truncation errrors occur when the numerical methods used for solving a
mathematical problem utilize an approximate mathematical procedure.

A simple example : For the numerical evaluation of sin(x), Taylor’s seris expansion can be used:

x 3 x 5 x 7 x 9 x 11
sin( x) = x − + − + − + ...
3! 5! 7! 9! 11!
The value of sin(π/6) can be determined exactly with the equation above if an infinite
number of terms are used.
The value can be approximated by using only a finite number of terms.
The difference between the true (exact) value and an approximate value is the
TRUNCATION ERROR (ETR)
The Taylor Series
Taylor theorem states that any smooth function can be approximated as
a polynomial
(The function f and its first n+1
derivatives are continuous on an interval
containing a and x)
Truncation error

x 3 x 5 x 7 x 9 x 11
sin( x) = x − + − + − + ...
3! 5! 7! 9! 11!

Π Π
If only the first term is used: sin( ) = = 0,5235988
6 6
The exact value : Π
sin( ) = 0,5
6
The truncation error ETR= 0,5 – 0,5235988 = - 0,0235988
3
Π
 
If only the two terms are used: Π Π 6
sin( ) = − = 0,4996742
6 6 3!

The truncation error ETR= 0,5 – 0,4996742 = 0,0003258


Errors in numerical solutions
Numerical Solution is an approximation.
Total error is also called TRUE ERROR.

True Error = Round off Error + Truncation Error


True Error = True Solution – Numerical Solution

This quantity which is non dimensional and scale-independent indicates how large the error is
relative to the true solution.
If expressed in percentage, it is called true percent relative error.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Errors in numerical solutions

The true error and the true relative error can not actually be
determined in problems that require numerical methods for their
solution since the true solution is not known. These error quantities can
be useful for evaluating the accuracy of different numerical methods.
This is done by using the numerical method for solving problems that
can be solved analytically and evaluating the true errors.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Errors in numerical solutions

Since the true errors cannot, in most cases, be calculated, other means
are used for estimating the accuracy of a numerical solution. This
depends on the specific method and is discussed in more detail later. In
some methods the numerical error can be bounded, while in others an
estimate of the order of magnitude of the error is determined. In
practical applications, numerical solutions can also be compared to
experimental results, but it is important to remember that experimental
data have errors and uncertainties as well.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Error definitions

For both error types: True value = approximation + error

Numerical (true) error: Et = True value - approximation

true error
True (fractional) relative error: True fractional relative error =
true value

true error
True percent relative error: εt = 100%
true value

approximate error
Approximate percent relative error: εa = 100%
approximation
Error definitions

For iterative approaches:

current approximation - previous approximation


εa = 100%
current approximation

Error may be positive of negative

Iteration is continued until εa < εs (stopping criterion)

Error can be related to the number of significant figures in the approximation

ε s = (0.5 ×102− n )% (Result correct to at least n significant figures)


Error definitions
Example
Truncation error
Truncation error
Truncation error
Accuracy and Precision

The errors associated with both


calculations and measurements can
be characterized with regard to
their accuracy and precision.

Accuracy relates to how closely a


computed or measured value agrees
with the true value

Precision relates to how closely


individual computed or measured
values agree with each other

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Accuracy and Precision

Inaccuracy (bias) : Systematic deviation from the truth


A variety of factors not included or underestimated in a model would result in
deviations from the prediction of the models. If these deviations are systematically
high or low, then we might need to develop a new model.

However, if they are randomly distributed and tightly grouped around the prediction,
then the deviations might be considered negligible and the model deemed adequate.
Numerical approximations also introduce similar discrepancies into the analysis.
Again, the question is: How much the next error is present in our calculations and is
it tolerable?

Imprecision (uncertainty) : Refers to magnitude of scatter

Error
Represents both inaccuracy and imprecision of predictions

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Accuracy and Precision

According to ISO 5725-1,


accuracy consists of
trueness (proximity of
measurement results to the
true value) and precision is
the repeatability or
reproducibility of the
measurements.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Accuracy and Precision

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Accuracy and Precision
The coefficient of variation (CoV) is the ratio of the standard deviation to
the mean. The higher the coefficient of variation, the greater the level of
dispersion around the mean. It is generally expressed as a percentage.
The lower the value of the coefficient of variation, the more precise the
estimate.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Before discussing the errors associated with numerical methods, it is useful to
review basic concepts related to approximate representation of the numbers
themselves.

• Whenever we employ a number in a computation, we must have assurance that


it can be used with confidence.
• The concept of a significant figure, or digit, has been developed to formally
designate the reliability of a numerical value.
• Significant figures are important because they tell us how good the data we are
using are.
• The significant digits of a number are those that can be used with confidence.
They correspond to the number of certain digits plus one estimated digit.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Numbers: Significant figures

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
Speed? the car is traveling at approximately 49 km/h. 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. It would be absurd to
Odometer? claim, on the basis of this speedometer, that the
automobile is traveling at 48.8642138 km/h.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
In contrast, the odometer provides up to six certain digits.
We 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.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
The concept of a significant figure, or digit, has been
developed to formally designate the reliability of a
numerical value.
The significant digits of a number are those that can be used
with confidence. They correspond to the number of certain
digits plus one estimated digit.
For example, the speedometer and the odometer yield
readings of three and seven significant figures, respectively.
For the speedometer, the two certain digits are 48. It is
conventional to set the estimated digit at one-half of the
smallest scale division on the measurement device. Thus 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.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Rules for Significant Figures
1. All non-zero numbers are significant. So we have to be careful!!!
The number 78.6 has three significant figures because all of the digits
present are non-zero.
2. Zeros between two non-zero digits are significant.
1071 has four significant figures.
3. Leading zeros are not significant. They're nothing more than "place holders."
The number 0.42 has only two significant figures.
0.0042 also has two significant figures. All of the zeros are leading.
4. Trailing zeros to the right of the decimal are significant.
There are four significant figures in 24.00.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Rules for Significant Figures
5. Trailing zeros in a whole number with no decimal may or may not be
significant depending on the precision of measurement.
Writing just "2300" indicates that the trailing zeros may not be
significant and there may be two or three or four significant figures in
this value.

6. Trailing zeros in a whole number with the decimal shown are significant.
Placing a decimal at the end of a number is usually not done. For
example, "2300." indicates that the trailing zero is significant, there are
four significant figures in this value.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Rules for Significant Figures
7. For a number in scientific notation: N x 10n, all digits comprising N are
significant by the first 6 rules; 4.030 x 105 has four significant figures.

This rule provides the opportunity to change the number of significant figures in a
value by manipulating its form.

For example, let's try writing 4500 with three significant figures. By rule 5, 4500 has
two significant figures; its two trailing zeros are not significant. If we add a decimal to
the end, we have 4500., with four significant figures (by rule 6.) But by writing it in
scientific notation: 4.50 x 103, we create a three-significant-figure value.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Or, trailing zeros in a number are significant if there is a decimal
point right after.
For example: 370
since it's not 370.0, you don't know if 370 is exact or an
estimate. So the 0 in 370 is not precise,
But if it's 370.0, there are now four significant figures

The 0’s after the number in 0.3453000 matter because it shows the
precision of the instrument used in the measurement.

Any zeros used as a placeholder for the decimal place, like 0.0025,
are insignificant.
Civil Engineering Faculty MAT 202E Numerical Methods
Number Significant figures
• Significant Figures: Digits that carry meaning
0.00001845 contributing to its measurement resolution
0.0001845
• Zeros placed before other digits are not significant. Ex:
0.001845 0.046 2 sig. fig.

• Zeros placed between other digits are always


significant. Ex: 4009: 4 sig. fig.
4.53x104
45,300 4.530x104 • Zeros placed after digits but behind a decimal point are
4.5300x104 significant.
Ex: 7.09: 3 sig. fig.

3 • Zeros at the end of a number are significant only if they


π 3.14 are behind a decimal point. To avoid uncertainty, use
3.14159265358 scientific notation.
Ex: 11.400: 5 sig. fig. ; 11400 ?
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering
Significant figures
Number Significant figures

0.00001845 4
0.0001845 4

0.001845 4

4.53x104 3
45,300 4.530x104 4
4.5300x104 5

3 1 Note that the number


π 3.14 3 of decimal places is
3.14159265358 12 another concept!

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
Mathematically there is no difference between the exact, precise numbers 5.0 and 5.00 and
5.000.
However for measurements in the real world (for science, engineering etc.) there is always a
limit to the precision of a measure. Someone wanting to make use of a measurement needs
to know how precise it is because they need to know how precise and accurate their final
result is.
5.00 is different from 5. A person who measures 5.00 mm knows his value to the nearest
1/100th mm, while one who measures 5 mm only knows his value to the nearest 1 mm. It's
important to understand that "zero" does not mean "nothing." Zero denotes actual
information, just like any other number.
It is the precision of the measuring device that decides the significant figures.

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Errors in numerical solutions

A common convention in science and engineering is to express accuracy


and/or precision implicitly by means of significant figures. Where not
explicitly stated, the margin of error is understood to be one-half the value
of the last significant place. For instance, a recording of 843.6 m, or
843.0 m, or 800.0 m would imply a margin of 0.05 m (the last significant
place is the tenths place), while a recording of 843 m would imply a margin
of error of 0.5 m (the last significant digits are the units).

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Errors in numerical solutions

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures

A measurement of 5.0 (2 SF) could be anywhere between 5.05 or 4.95


A measurement of 5.00 (3 SF) could be in reality anywhere between 5.005 and 4.995
A measurement of 5.000 (4 SF) could be in reality anywhere between 5.0005 and 4.9995.
Measuring the carpet to cover a floor as 5.0 Meters (2SF) by 6.0 Meters (2SF) means the area
could be as little as 4.95x5.95= 29.45 m2.
However, at that precision the area could be 5.05x6.05 = 30.55 m2.
That is a difference of 1.1 m2!

Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering


Significant figures
The concept of significant figures has two important implications for our study of
numerical methods:
1. Numerical methods yield approximate results. We must, therefore, develop
criteria to specify how confident we are in our approximate result. One way to do
this is in terms of significant figures. For example, we might decide that our
approximation is acceptable if it is correct to four significant figures.

2. Although quantities such as π, e, or √7 represent specific quantities, they can not


be expressed exactly by a limited number of digits.
For example, π = 3.141592653589793238462643. . ad infinitum.
Because computers retain only a finite number of significant figures, such numbers
can never be represented exactly. The omission of the remaining significant figures
is called round-off error.
Civil Engineering Faculty INS 202E Numerical Methods in Civil Engineering

You might also like