Part3 Errors
Part3 Errors
Computing Methods in
Engineering
by
ERRORS IN ENGINEERING
CALCULATIONS
This type of error is the type of error made when expressing an engineering
problem. It arises from simplifying assumptions made on the problem to facilitate
the expression and solution of the engineering problem and to reduce the solution
time. Below are simple examples of modeling errors.
For example, the area of a circle can be expressed as in Figure 3.1 by adding
different number of triangles.
Figure 3.1: Representation of the area of the circle by the sum of different numbers
of triangles.
Increasing the number of triangles in Figure 3.1 will cause the area to be expressed
more accurately. Therefore, among the three models in Figure 3.1, the area of the
circle represented by 4 triangles (Model 1) will be the most inaccurate, and the
area of the circle represented by 6 triangles (Model 3) will be the most accurate.
Increasing the number of triangles will reduce the modeling error.
Stress calculation in the bar :
In Figure 3.2 below, the stress formed in the bar under the F force is tried to be
calculated. The actual Stress–Strain ( − ) plot is nonlinear. However, linear
Stress–Strain graph, known as Hooke's Law, is used in stress calculations because
it is easy and simple in applications . Using a linear Stress–Strain plot instead of a
true nonlinear Stress–Strain plot often leads to an acceptable modeling error in
engineering applications.
Real
Figure 3.2: Calculation of the real (nonlinear) and linear material model of the
stress in the bar.
Modeling errors, examples of which are given above, are errors that can be
reduced or avoided.
3. 2 PROCESSING ERRORS
Process errors are the types of errors that occur as a result of mathematical
operations in the solution of engineering problems. These errors are divided into 2
groups as 1) Rounding errors, 2) Cutting errors.
In computer calculations, a certain number of digits are reserved for each variable
or number in the computer memory. If the calculated variable value is greater than
the allocated digit value, a) either the extra digits in the variable are trimmed
(trimmed), or b) the variable value is rounded to fit the allocated space in memory
. For example 2 , and consists of digits whose number continues to infinity. The
use of these numbers in calculations requires rounding or trimming in the computer
environment.
For example, taking the first 15 digits of the decimal part of the number pi =
Let's think of it as 3.142857142857143. This variable can be rounded as follows
Table 3.1: rounding and trimming the number for different numbers of digits
(digits), errors in this case.
pi = 3.142857142857143…
Value used in place Rounding Error (pi- Value used Crop Error
of Pi (with value) instead of pi (pi-value)
Rounding) (with cutting)
3.14285714285714 -0.001264489267347 3.14285714285714 -0.001264489267347
3.1428571428571 -0.001264489267207 3.1428571428571 -0.001264489267307
3.142857142857 -0.001264489267307 3.142857142857 -0.001264489267207
3.14285714286 -0.001264489270207 3.14285714285 -0.001264489260207
3.1428571429 -0.001264489310207 3.1428571428 -0.001264489210207
3.142857143 -0.001264489410207 3.142857142 -0.001264488410207
3.14285714 -0.001264486410207 3.14285714 -0.001264486410207
3.1428571 -0.001264446410207 3.1428571 -0.001264446410207
3.142857 -0.001264346410207 3.142857 -0.001264346410207
3.14286 -0.001267346410207 3.14285 -0.001257346410207
3.1429 -0.001307346410207 3.1428 -0.001207346410207
3.143 -0.001407346410207 3.142 -0.000407346410207
3.14 0.001592653589793 3.14 0.001592653589793
3.1 0.041592653589793 3.1 0.041592653589793
3 0.141592653589793 3 0.141592653589793
In engineering calculations, if the variables are not integers and are too large to
fit into the allocated digits in the memory, errors occur due to rounding or
truncation to fit into memory.
Sometimes a variable that fits in the memory may not fit in the memory allocated
digits after mathematical operations. For example, let's assume that a maximum
of 4 digits can be allocated in the memory for the variable x x . Let's say the value
of in x =0.0001 and it fits in 4 digit memory. As a result of a mathematical
operation 𝑥 2 = 0.0000 on this variable, the 8-digit x value will actually
2
⏟
0001
𝑢𝑛𝑛𝑒𝑐𝑒𝑠𝑠𝑎𝑟𝑦 𝑑𝑖𝑔𝑖𝑡𝑠
be obtained . If this variable is tried to fit into 4 digits, x = 0.0000 it will have its
2
value after rounding. In this case , there will be a difference between the true
value and the rounded value, that is, an error. 0.00000001
x
Example 3.1 : By taking y = x + + 2 x103 x the result of the operation x
2
3
10
=0.0001 and assuming y that 4 digits can be allocated to the variables in the computer memory
, find the true value, the rounded value and the difference between the true value
and the rounded value, namely the error?
x
y = x2 + 3
+ 2 x103 x The actual value of the function x can be calculated by taking
10
=0.0001 as follows:
y=(0.0001)^2+0.0001/1000+2000*0.0001=0.00000001+0.0000001+0.2
=0.20000011
y=(0.0001)^2+0.0001/1000+2000*0.0001=0.0000+0.0000+0.2=2
Computers use the binary system of 0.1 numbers and allocate memory space for
variable values in binary or base memory. Therefore, they store the values in the
decimal system in daily calculations by converting them to the binary system.
Variables are represented by a certain number of digits (bits) in a binary system
called words in computer memory. These words are represented by bits 2 times
the previous one, such as 4-bit, 8-bit, 16-bit, 32-bit, 64-bit. A large number of bits
allows large values to be stored in memory without rounding or clipping. Small
numbers of bits cause errors as they cause variables to be rounded or truncated.
Rounding or clipping errors are caused by mathematical operations, because the
value of the variable does not fit into the allocated digits in the memory.
x = d n −1 d n − 2 ...d1 d 0 x = d n −1 2 n −1 + d n − 2 2 n − 2 + ... + d1 21 + d 0 2 0
n bit
Table 3.2 below shows the 2-bit equivalent of the values to be stored in the decimal
system.
Table 3.2: Minimum and maximum values of variables that can be stored in the
binary system.
If any integer is outside the (min, max) range in Table 3.2, it cannot be
represented exactly by the bit numbers in Table 3.2. To reduce rounding or clipping
errors, single precision (7-8 bits) or double precision (15-16 bits) should be used,
which increases the number of bits allocated to variables in computers in
mathematical operations.
A decimal number can be converted to binary using the remainder after dividing
by 2 consecutively. For example, the number 20 can be expressed in base 2 by
dividing it by 2 and using the remainder ( by writing the remainder backwards
from the beginning ) until the quotient becomes zero, as in Table 3.3 :
20=10100➔ 20 = 1x2 + 0 x2 + 1x2 + 0 x2 + 0 x2
4 3 2 1 0
Fractional numbers are more difficult to express than whole numbers. Fractional
numbers can be expressed in binary a) fixed point and b) floating point methods.
Example 3.2 : Calculate the value of x =1011.101 with fixed point notation?
x a number 𝑥 = 1011.101 = ⏟ 𝑑−1 𝑑−2 𝑑−3 . Its value is Equation 1.1. can be
𝑑3 𝑑2 𝑑1 𝑑0 . ⏟
𝑖𝑛𝑡𝑒𝑔𝑒𝑟_𝑡𝑒𝑟𝑚𝑠 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛_𝑡𝑒𝑟𝑚𝑠
calculated using the following:
𝑑3 23 + 𝑑2 22 + 𝑑1 21 + 𝑑0 20 + ⏟
𝑥=⏟ 𝑑−1 2−1 + 𝑑−2 2−2 + 𝑑−3 2−3
𝑖𝑛𝑡𝑒𝑔𝑒𝑟_𝑡𝑒𝑟𝑚𝑠 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛_𝑡𝑒𝑟𝑚𝑠
3 2 1 0 −1 −2 −3
=⏟
1𝑥2 + 0𝑥2 + 1𝑥2 + 1𝑥2 + ⏟
1𝑥2 + 0𝑥2 + 1𝑥2 = 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
𝑖𝑛𝑡𝑒𝑔𝑒𝑟_𝑡𝑒𝑟𝑚𝑠 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛_𝑡𝑒𝑟𝑚𝑠
= 11.625
In fixed-point notation, many digits (digits) are needed to express very large and
very small numbers (fractions). Floating point notation has been developed to
store these numbers more efficiently in computers. In this notation, it is
represented as a fractional variable like 𝑥 = (𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛_𝑡𝑒𝑟𝑚)𝑥(𝑏𝑎𝑠𝑒)ü𝑠 any x . In the
representation of a fractional number with the floating point system, the number
is normalized with a single digit before the fraction. For example, the number 25.34
can be represented as a base 10 floating point system 0.2534x10 .
2
Fractional numbers are shown as in Table 3.4 by separating bits to the sign of the
fractional number, the fraction part, the exponent and its value with the floating
point system. While fractional numbers are expressed in binary, the first bit of the
number is used for the sign of the number, the next bit is used for the sign of the
exponent, the following bits are used for the value of the exponent, and the last
bits are used to represent the fraction part of the fractional number. In the binary
system, the positive sign is represented by the number 0 and the negative sign by
the number 1.
Table 3.4: Floating point representation of fractional numbers in the binary system.
, let's assume that a total of 8 bits are allocated in memory for a variable. x Let's
say the first bit of the 8 bits is reserved for the sign of the number, the next 3 bits
are reserved for the exponent (1 bit sign, 2 bits for the number), and the remaining
4 bits are reserved for the fractional number. In this case, if the variable x is
expressed as x =11101010 in binary , its floating point equivalent can be
expressed as follows
𝑠𝑖𝑔𝑛 𝑒𝑥𝑝𝑜𝑛𝑒𝑛𝑡 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛
𝑥 = ⏞⏟
1 ⏟
1 ⏞
⏟ 0 ⏞⏟
1 ⏟ 1 ⏟
0 ⏟
1 ⏟
0 ➔
𝑘𝑒𝑠𝑖𝑟 ü𝑠 𝑑1 𝑑0 𝑑−1 𝑑−2 𝑑−3 𝑑−4
( )
x = − 1x 2 −1 + 0 x 2 − 2 + 1x 2 −3 + 0 x 2 − 4 x 2 − (1x 2 + 0 x 2 ) = −0.625 x 2 − 2
1 0
It is seen from the above expression that the sign of the fraction and the exponent
is expressed with 1 in the binary system. From this, it is understood that the sign
of the fraction and its exponent is negative. The expression obtained above can be
−2
expressed as x = −0.625x2 decimal x = −0.15625 .
x 0 the value and derivatives of the function at point f ( x0 ) and f ' ( x0 ) , f '' ( x0 ) ,
f ''' ( x0 ) ,…, are known, the constants f ( n ) ( x0 ) , a1 , a 2 ,…, a n in the polynomial can be
determined by substituting the known values in the above equations a 0 as follows
x = x0 for f ( x) = f ( x0 ) ➔ a0 = f ( x0 ) (3.7)
f '' ( x0 )
x = x0 for f '' ( x) = f '' ( x0 ) ➔ a2 = 2! f '' ( x0 ) ➔ a2 = (3.9)
2!
f ''' ( x0 )
x = x0 for f ''' ( x ) = f ''' ( x0 ) ➔ a3 = (3)(2) f ''' ( x0 ) ➔ a3 = (3.10)
3!
3!
….
f ( n ) ( x0 )
x = x0 for f ( n ) ( x) = f ( n ) ( x0 ) ➔ an = n(n − 1)(n − 2)....(1) f ( n ) ( x0 ) ➔ an = (3.11)
n!
n!
If the constants obtained above are substituted in Equation X.1, the Taylor series
can be written as follows
f '' ( x0 ) f ( n ) ( x0 ) f ( n ) ( x0 )
f ( x) = f ( x0 ) + f ' ( x0 )( x − x0 ) + ( x − x0 ) 2 + ... + ( x − x0 ) n + ... = ( x − x0 ) n
2! n! n =0 n!
(3.12)
the Taylor series, x0 = 0 the Taylor series is called the Maclurin series and is
expressed as
f '' (0) 2 f '' (0) 3 f ( n ) (0) n f ( n ) (0) n
f ( x) = f (0) + f ' (0) x + x + x + ... + x + ... = x (3.13)
2! 3! n! n =0 n!
the Maclurin series , the polynomial equivalent of the functions can be obtained.
Each term of the above series expression has exponentiation, multiplication and
division operations. Therefore, rounding errors may occur in each term of the
series. Increasing the number of terms to reduce the truncation error may increase
the rounding error as it will cause mathematical operations for more terms. In
short, increasing the number of terms in the series decreases the truncation error
and increases the rounding errors.
Example 3.3 : f ( x) = e x Get the polynomial equivalent of the function with the
Maclurin series?
x 2 x3 x 4 xn xn
e = 1 + x + + + + ... +
x
=
2! 3! 4! n! n =0 n!
Example 3.4 : f ( x) = sin x Obtain the polynomial equivalent of the function with
the Maclurin series?
f ( x) = sin x The values f (0) = sin 0 = 0 of the function and its derivatives at the point
can be expressed as x0 = 0 , f (0) = cos 0 = 1 , f (0) = − sin 0 = 0 , f (0) = − cos 0 = −1 ,
' '' '''
Using this function and its derivative values, f ( x) = sin x the function can be
expressed with the Maclurin series as follows
x3 x5 x7
(−1) n 2 n +1
sin x = x − + − + ... = x
3! 5! 7! n = 0 ( 2n + 1)!
As seen from the examples above e , , sin x and all other functions can be
x
expressed in terms of polynomials with the Maclurin series. But since these series
contain an infinite number of terms, they continue indefinitely. Therefore, for
practical use of these series, they must be truncated after a certain number of
terms have been taken. The error that occurs due to the use of series by cutting
is called truncation error.
The Taylor series can be written with the terms after R(x) the n -ci derivative as
follows:
f '' ( x0 ) f ( n ) ( x0 ) f ( n +1) ( x0 )
f ( x) = f ( x0 ) + f ' ( x0 )( x − x0 ) + ( x − x0 ) 2 + ... + ( x − x0 ) n + ( x − x0 ) n +1 + ...
2! n! (n + 1)!
R
the n -ci derivative are omitted in the Taylor series, the truncation error can be
expressed as
f ( n +1) ( x0 ) f ( n+1) ( )
R= n +1
( x − x0 ) + ... = ( x − x0 ) n+1 x0 x
(n + 1)! (n + 1)!
from the above expression that the order of the truncation error ( x − x0 ) n +1 can be
expressed as . The truncation error is a controllable error since any number of
terms can be selected from the series.
Example 3.5 : Calculate a) e the value of b) sin the value of by taking a
2
4
different number of terms from the Maclurin series?
x2 x3 x 4 xn
a) It is expressed as a function e x = 1 + x + + + + ... + of the Maclurin
2! 3! 4! n!
series . e
x
2 2 23 2 4 2n
In this case, e the value e 2 = 1 + 2 + + + + ... + can be expressed as
2
2! 3! 4! n!
x3 x5 x7
b) It is expressed as a function sin x = x − + − + ... of the Maclurin series
3! 5! 7!
. sin x
( / 4) 3 ( / 4) 5 ( / 4) 7
In this case, sin the value sin( / 4) = ( / 4) − + − + ... can be
4 3! 5! 7!
expressed as
When a different number of terms are taken from the Maclurin series e and sin
2
4
for their values, the values in Table 3.5 are obtained.
Table 3.5: Calculation of e and sin values with Taylor series using different term
2
4
numbers.
2 sin =0.707106781186547 (True)
e = 7.389056098930650 (True) 4
from Table 3.5 e that 9-10 terms from the series and sin
2
2-3 terms from the series
4
give very close results to the accepted value.
the current iteration k represents the previous iteration k -1 and f the solution
value, the iteration error at the k -th iteration can be expressed as:
f k − f k −1
E= (3.14)
f k −1
The iteration error in Equation 1.14 is more commonly used in iterative solutions.
in Equation 1.15 is never zero due to rounding, clipping and truncation errors in
computers.
Depending on the iterative method chosen in iterative solutions, the solution error
in each iteration will also be different. While some methods reduce the errors in
iterations rapidly, some can reduce them slowly or increase the errors even more
if certain initial conditions are not met.
The iteration error in solving engineering problems is usually larger than the
rounding, trimming, and truncation errors. For this reason, the most critical step
in solving engineering problems is to determine the most appropriate iterative
method that will solve the problem accurately and quickly. The iteration error can
be reduced or kept under control by choosing an appropriate method for the
solution.
Simple Iteration and Newton-Raphson methods and indicate the errors in each
iteration?
This equation x = −5 , x = 3 There are two real solutions. Let's try to obtain these
solutions with numerical methods (Simple Iteration and Newton-Raphson
methods). These methods are described in detail in Chapter 4. They will only be
briefly stated here.
a) Simple iteration
15 15
x 2 + 2 x = 15 ➔ x( x + 2) = 15 ➔ x = ➔ xk =
x+2 xk −1 + 2
15
x0 = 2 the initial value is selected and the above xk = iterative solution
xk −1 + 2
expression is used, the results in Table 3.6 are obtained.
b) Newton-Raphson method
f ( xk −1 ) xk2−1 + 2 xk −1 − 15
xk = xk −1 − ➔ x = xk −1 −
2 xk −1 + 2
k
f ' ( xk −1 )
xk2−1 + 2 xk −1 − 15
x0 = 2 the initial value is selected and the above xk = xk −1 − iterative
2 xk −1 + 2
solution expression is used, the results in Table 3.6 are obtained.
It is seen from Table 3.6 that the Newton-Rapson method causes lower errors in
each iteration (step) and converges to the correct result faster than the Simple
Iteration method.
SECTION SUMMARY