Professional Documents
Culture Documents
Lecture 03-20220804
Lecture 03-20220804
You Can Lead a Horse to Water …
CE‐603
Numerical Methods
Prof. Ravi Sinha
(rsinha@civil.iitb.ac.in)
Lecture 03 – Thursday, August 4, 2022
CE‐603 Numerical Methods | Autumn Semester 2022‐23 2
1. Mathematical Background – Functions
Taylor’s Theorem
Let f(x) have n continuous derivatives on [a, b] for some n, and let x , x0 a , b]
Mathematical Background: Then, f (x) pn (x) Rn1 (x)
where,
Functions & Vectors Norms (x x0 )
pn (x) f ( x0 )
1!
f ( x0 )
( x x0 )n (n)
n!
f ( x0 )
Any continuous function can
be approximated by a
(n 1)
polynomial function and a
( x x0 )
x
1
Rn1 (x) ( x t )n f (n1) (t )dt f (n1) ( ) remainder term (whose
n! x0 (n 1)! value is generally unknown)
for some between x0 and x
pn (x) is a polynomial of order n
CE‐603 Numerical Methods | Autumn Semester 2022‐23 3 CE‐603 Numerical Methods | Autumn Semester 2022‐23 4
04‐08‐2022
CE‐603 Numerical Methods | Autumn Semester 2022‐23 5 CE‐603 Numerical Methods | Autumn Semester 2022‐23 6
2. Mathematical Background –Vectors Norm Know your mobile device!
Most important vector norms: 1. How much memory (RAM) dues your mobile phone have?
x 1 x1 ... xn , x n 1‐Norm
2. Is the amount of memory a round number? Why not?
xT x ,
1/2 1/2
x 2 x12 ... xn2 x n 2‐Norm 3. How many bytes does a kilobyte consist of?
x
max xi , x n ‐Norm
1i n
Note: All vector norms are considered equivalent even if their numerical values differ!
Some characteristic properties of vector norms are:
v 0, if and only if v 0 , the null vector
v . v , for all vectors v and real numbers
v w v w , for all vectors v & w n
CE‐603 Numerical Methods | Autumn Semester 2022‐23 7 CE‐603 Numerical Methods | Autumn Semester 2022‐23 8
04‐08‐2022
Number Representation
It is essential to understand how numbers are represented in computers, and the
consequences on computer arithmetic.
Computer Representation Number representation:
1. Integer (Fixed point) mode – Used to exactly represent integer numbers. Not of much
interest in Numerical Methods course.
of Numbers 2. Floating point mode – Used to represent real numbers. The permitted numbers can vary
greatly in size. However, there are limitations on both (a) magnitude of numbers, and (2)
accuracy of their representation.
Number base used in computers in not decimal (Order of magnitude does not change by 10).
a) Most computers – binary (base 2)
b) Some computers – Hexadecimal (base 16)
CE‐603 Numerical Methods | Autumn Semester 2022‐23 9 CE‐603 Numerical Methods | Autumn Semester 2022‐23 10
Integer (Fixed Point) Number Representation Floating Point Number Representation
Integer Mode: Floating point numbers are stored on a computer as follows:
oNot of much interest in this course. x .a1a2 ...at e
oIntegers are represented exactly.
where
oImportant ‐ Integers can only be represented within a range.
radix (or base being used)
L Smallest integer represented in computer (negative number)
Sign function ( 1 or 1)
U Largest integer represented in computer (positive number)
.a1a2 ...at mantissa; values are 0 ai 1
e exponent (an integer)
The numbers in parenthesis (mantissa) represent the following number:
a a a
.a1a2 ...at 11 22 ... tt
CE‐603 Numerical Methods | Autumn Semester 2022‐23 11 CE‐603 Numerical Methods | Autumn Semester 2022‐23 12
04‐08‐2022
Floating Point Number Representation Floating Point Number Representation
Binary Numbers: Example 1 (binary to decimal number)
ai can have values of 0 or 1 11011.012 1 24 1 23 0 22 1 21 1 20 0 21 1 22
Hexadecimal Numbers: 16 8 2 1 0.25 27.25
ai can have values of 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, A, B, C, D, E, F
Example 2 (hexadecimal to decimal number)
oThe hexadecimal numbers A‐F are
equivalent to decimal numbers 10‐15 56C .F 16 5 162 6 161 12 160 15 161
oCheck your scientific calculator for 1280 96 12 0.9375 1388.9375
hexadecimal keys
CE‐603 Numerical Methods | Autumn Semester 2022‐23 13 CE‐603 Numerical Methods | Autumn Semester 2022‐23 14
Concept:
Floating Point Number Representation Floating‐Point Number Representation
When writing a large number of digits
Example 3 (decimal to binary number) Decimal by hand, they should be grouped with
Example (decimal to binary number) Decimal
516.4 32910 1 29 ... 1 29 ...
516.432910space between groups. This makes
29 28 27 26 25 24 23 22 21 20 2‐1 comprehension of numbers easier
29 28 27 26 25 24 23 22 21 20 2‐1
ai 1 0 0 0 0 0 0 1 0 0 0 ai 1 0 0 0 0 0 0 1 0 0 0
Value 512 4 Value 512 4
Sum 512 516 Sum 512 516
Remainder 4.432 9 0.4329 Remainder 4.432 9 0.4329
Group of 4 digits are most commonly
2‐2 2‐3 2‐4 2‐5 2‐6 2‐7 2‐8 2‐9 2‐10 2‐11 2‐12 2‐2 2‐3 2‐4 2‐5 2‐6 2‐7 2‐8 2‐9 2‐10 2‐11 2‐12
adopted.
ai 1 1 0 1 1 1 0 1 1 0 1 ai 1 1 1 1 1 1 1 1
0.0312 5 0.0156 25 0.0078 125 0.0019 5312 5
Check your bank’s debit or credit card
0.0312 5 0.0156 25
0.0078 125 0.0019 5312 5
Value 0.25 0.125 … … Value 0.25 0.125 … …
Sum 516.2 5 516.3 75 516.4 0625 516.4 2187 5 516.4 2968 75 516.4 3165 06
… … Sum 516.2 5 516.3 75
number for its grouping!
516.4 0625 516.4 21875 516.4 2968 75
… 516.4 3165 06
…
0.0266 5 0.0110 25 0.0032 125 0.0012 5937 5 0.0266 5 0.0110 25 0.0032 125 0.0012 5937 5
Remainder 0.1829 0.0579 … … Remainder 0.1829 0.0579 … …
CE‐603 Numerical Methods | Autumn Semester 2022‐23 15 CE‐603 Numerical Methods | Autumn Semester 2022‐23 16
04‐08‐2022
Floating Point Number Representation Floating Point Number Representation
Example 3 (decimal to binary number) (contd.) Decimal to binary number conversion
1
516.4 32910 1 29 ... oAs observed in the example, very large number of binary digits or terms may
215
After 25 binary digits, we get the following: be required to represent a typical decimal number.
sum 516.4 3289 18 oSo, can we use any number of digits to convert a decimal number to binary?
remainder 0.0000 0818 2 oNo
Note that even after using 25 binary digits, the number is not exactly represented in binary oAre there limits on number of binary digits used on a computer?
form. oYES!
After 25 digits, the conversion to binary form is:
oThe number of available binary digits depends on precision of floating point
516.4 32910 1000 0001 00.01 1011 1011 0100 1 2 number representation.
CE‐603 Numerical Methods | Autumn Semester 2022‐23 17 CE‐603 Numerical Methods | Autumn Semester 2022‐23 18
CE‐603 Numerical Methods | Autumn Semester 2022‐23 19 CE‐603 Numerical Methods | Autumn Semester 2022‐23 20
04‐08‐2022
CE‐603 Numerical Methods | Autumn Semester 2022‐23 21 CE‐603 Numerical Methods | Autumn Semester 2022‐23 22
End of Lecture 03
CE‐603 Numerical Methods | Autumn Semester 2022‐23 23