0% found this document useful (0 votes)
60 views

CHE 374 Computational Methods in Engineering: Numbers

This document discusses number representation in computers. It begins by distinguishing between integer and real numbers, and explains that in computers, numbers are represented as either integers (fixed point) or floating point. It then discusses how decimal and binary systems are used to represent numbers in computers through sequences of 0s and 1s. The document also summarizes floating point representation and how it allows fractions and large numbers to be stored, but introduces rounding errors. It concludes by discussing different types of errors that can occur in computations due to rounding and truncation.

Uploaded by

Akib Imtihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

CHE 374 Computational Methods in Engineering: Numbers

This document discusses number representation in computers. It begins by distinguishing between integer and real numbers, and explains that in computers, numbers are represented as either integers (fixed point) or floating point. It then discusses how decimal and binary systems are used to represent numbers in computers through sequences of 0s and 1s. The document also summarizes floating point representation and how it allows fractions and large numbers to be stored, but introduces rounding errors. It concludes by discussing different types of errors that can occur in computations due to rounding and truncation.

Uploaded by

Akib Imtihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CHE 374 LEC # 3 Number representation, Approximations and Errors

Numbers
• We distinguish between integer numbers
and real numbers
324 is an INTEGER number
CHE 374 Computational Methods 1.426
Π
is a REAL number
is a REAL number

in Engineering
• In computers, numbers are represented
Number representation, approximation, error either as INTEGERS (fixed point numbers)
and error definitions or as FLOATING POINT numbers )
1.426 (or 1.426e0 or 0.1426e+1 ….)

1 2

• Computers are digital machines. They


store numbers as a string of zero’s and Decimal (base 10) Representation
ones
102 101 100 10-1 10-2 10-3
Example INTEGERS represented in a 16 bit system
7 5 4 . 3 5 6
1 = 0000000000000001 =20 7x102 5x101 4x100 3x10-1 5x10-2 6x10-3
2 = 0000000000000010 =21
754.356
3 = 0000000000000011 =20+21
128 = 0000000010000000 =27
131 = 0000000010000011 =27+21+20
Representation of the number 754.356 in the decimal system

3 4

Computational Methods in Engineering 1


CHE 374 LEC # 3 Number representation, Approximations and Errors

Binary (base 2) Representation Storing a number in computer memory

22 21 20 2-1 2-2 2-3

1 0 0 . 1 0 1
1x22 0x21 0x20 1x2-1 0x2-2 1x2-3
1x4 0x2 0x2 1x0.5 0x0.25 1x0.125 Computer representation of a real number
4.625

Representation of the number 4.625 in the binary system 32 bit computer


5 6

Floating point representation Floating Point Representation


• Fractional quantities are typically represented in
• Floating point representation allows both
computer using “floating point” form, e.g.,
fractions and very large numbers to be
expressed on the computer. However,
Integer part – Floating point numbers take up more room.
exponent
m.be – Take longer to process than integer numbers.
mantissa Base of the number system
used
– Round-off errors are introduced because
mantissa holds only a finite number of
significant figures.

7 8

Computational Methods in Engineering 2


CHE 374 LEC # 3 Number representation, Approximations and Errors

Chopping and Rounding Another example


Example:
e = 2.718281828459046 to be stored on a base-10
>> x = 29/1300
system carrying 7 significant digits. x = 0.02230769230769
e=2.718281 chopping error >> y = 29 - 1300 * x
et = 8.284590453655483e-007 y = 3.552713678800501e-015
The round-off error occurs when x is stored, 29/1300
If rounded
e=2.718282
et = -1.715409543301405e-007
• Some machines use chopping, because rounding adds
to the computational overhead. Since number of
significant figures is large enough, resulting chopping
error is negligible.
9 10

Errors in Computation Truncation errors


• Errors caused by use of truncated (shortened)
solution from an infinite series solution
• How confident we are in our
approximate result? We have already seen the approximation to the first derivative:
• The real question is “how much error
dv v v(tt 1 )  v (ti )
can we tolerate in our calculation” 
dt t

tt 1  ti

Can we estimate the error??

dv v (ti1 )  v(ti ) (1)


 e
dt ti1  ti
YES WE CAN !!!
11 USE Taylor series expansion of v(ti+1) around ti to find e 12

Computational Methods in Engineering 3


CHE 374 LEC # 3 Number representation, Approximations and Errors

1 1
v(t i  t )  v(t i 1 )  v(ti )  v t  v  t   v  t   ...
2 3

2! 3!

v(t i1 )  v (ti )  v t  R1

Dividing by ∆t and rearranging


v(t i1 )  v(ti ) dv(ti ) v(t i1 )  v(ti ) R
 v   R1 / t   1
or t dt t
  (t )
dv v (t i 1 )  v (ti ) R first order truncation
  1 approximation error
t
dt  (
  t )
1st order truncation
approximation error

Comparing with equation (1), we deduce that


1 d 2v 1 3
2 d v
e   t  2  t  3  ...  t 
2 dt 6 dt 13 14

Other sources/types of errors Error Definition


• Model errors – errors due to inadequate
representation of the physical model or parts True Value = Approximation + Error
of the model
et =true error= True value – Approximation
• Blunders and Mistakes - errors caused by
{may be positive or negative (+/-) }
malfunctions of the computer or human
imperfection.
Absolute error = |True value – Approximation|
• Data / input uncertainty - errors resulting from {always positive}
the accuracy and/or precision of the data.

15 16

Computational Methods in Engineering 4


CHE 374 LEC # 3 Number representation, Approximations and Errors

Error Definition Error definition


• In computations, we usually do not know the true
true error value. We can use the approximate value
relative error, er 
true value
 i n a n it e r a t iv e p r o c e s s :

true error ea
percent relative error, er %  100
true value
xi 1  xi
ea %   100%
xi 1
17 18

Q: What is the speedometer


Significant Figures
reading?
• Number of significant figures indicates
precision. Significant digits of a number are
those that can be used with confidence, e.g.,
the number of certain digits plus one
estimated digit.
35,700 How many significant figures?

3.57 x 104 3
3.570 x 104 4
3.5700 x 104 5
19 20

Computational Methods in Engineering 5


CHE 374 LEC # 3 Number representation, Approximations and Errors

Significant Figures Accuracy and Precision

Zeros are sometimes used to locate the


decimal point not significant figures.
0.00001753 4
0.0001753 4
0.001753 4

21 22

Accuracy and Precision


• Accuracy. How close a computed or measured
value is to the true value
• Precision (or reproducibility). How close a
computed or measured value is to previously
computed or measured values.
• Inaccuracy (or bias). A systematic deviation
from the actual value.
• Imprecision (or uncertainty). Magnitude of
scatter.
23

Computational Methods in Engineering 6

You might also like