Understanding Number Systems in Computing
Understanding Number Systems in Computing
Is a set of values used to represent different quantities. For example, a number system can
be used to represent the number of students in a class or number of viewers watching a
certain TV program etc. The digital computer represents all kinds of data and information
in binary numbers. It includes audio, graphics, video, text and numbers. The total number
of digits used in a number system is called its base or radix.
The decimal number system is used in general. However, the computers use binary number
system. The octal and hexadecimal number systems are used in the computer.
104 103 102 101 . 10-1 10-2 10-3 10-4 Power base
4 3 2 1 . 1 2 3 4 position
1 1 1 1 value
1000 100 10 1 . 10 100 1000 10000
1
Computational mathematics………mathematics is a life style……live it…
Converted
CPU
to
Human Input works on
computer
message the data
language
Decoded
to human
language
Human
readable
data
2
Computational mathematics………mathematics is a life style……live it…
3
Computational mathematics………mathematics is a life style……live it…
Types of data
Numeric data
Alphabetic data
Alphanumeric data
Solution
1111001
For fraction numbers, the number is divided into two parts, the whole number part and the
fraction part.
The whole number part is converted as shown above.
The fraction part is repeatedly multiplied by 2, noting the complete units of two. The
process proceeds until the fraction becomes a zero or starts recurring.
4
Computational mathematics………mathematics is a life style……live it…
Examples:
10100011.11
11001010.11100
5
Computational mathematics………mathematics is a life style……live it…
The number in binary is assigned weighted factors (place values) for each digit, and
then partial products i.e. the product of each digit and its corresponding weight, is
got.
These partial products are then summed up to give a decimal number equivalent of
the binary number.
26 25 24 23 22 21 20
1 1 1 1 0 0 1
64 + 32 + 16 + 8 + 0 + 0 + 1
12110
For the fraction part, digits are divided by multiples of two starting from the binary
point
24 23 22 21 20 . 2-1 2-2
1 1 0 1 0 . 0 1
1
16 + 8 + 0 + 2 + 0 + 0 + 4
26.2510
1 1 1 0 0 0 1 0 . 1 1 0 1
1 1 1
128 + 64 + 32 + 0 + 0 + 0 + 2 + 0 + + + 0 +
2 4 16
226.812510
…..property of keiway mining and technology college………compiled by Mr. Mutuku………
6
Computational mathematics………mathematics is a life style……live it…
Solution
12638
For fraction numbers, the number is divided into two parts, the whole part and the
fraction part.
Solutions
142.18
7
Computational mathematics………mathematics is a life style……live it…
Solutions
312.714638
Procedure is the same as binary to decimal, but the weights are assigned in terms of
8’s
Solutions
83 82 81 80
1 2 6 3
512 + 128 + 48 + 3
69110
For fraction number, conversion is the same as converting fraction binary number to
decimal, but the division is by multiples of 8.
8
Computational mathematics………mathematics is a life style……live it…
Solutions
82 81 80 . 8-1 8-2
2 4 3 . 6 4
6 4
128 + 32 + 3 + +
8 64
163.812510
Solutions
But A = 10
For fraction number, the fraction part is multiplied by 16 noting the complete units of 16’s.
Solutions
20.216
9
Computational mathematics………mathematics is a life style……live it…
The same procedure as from binary to decimal is used with weights assigned in terms of
16’s.
Solutions
161 160
7 A
112 + 10
12210
For fractional hexadecimal values, the division is by 16’s though the procedure is the same
as the binary fractions to decimal.
Solutions
2 0 . 2
2
32 + 0 +
16
32 + 0.125
32.12510
Negative numbers
Both negative and positive numbers can be represented in computer memory during
processing
10
Computational mathematics………mathematics is a life style……live it…
The negative numbers are used to carry out subtraction in the computer’s arithmetic
operations.
This is based on the notation that subtracting a number is same as adding its negative to the
number.
In this method, the binary bits representing the negative number are negated. I.e. the 1’s in
the number are changed to 0’s and 0’s to 1’s.
1710 = 100012
-1710 = 011102
In this method, the negative number is represented into binary, then complemented as in 1C
method but a 1 is added to the least significant digit of the complemented value.
1710 = 100012
-1710 = 01110
+ 1
01111
Conventionally, a ‘1’ is used to represent a negative sign and a ‘0’ to represent a positive
sign.
The binary digits therefore will be having part of them representing the data while the
others the sign bit
11
Computational mathematics………mathematics is a life style……live it…
For example;
1710 = 100012
-1710 = 1 100012
(Sign bit) (Data bit)
+1710 = 0 100012
(Sign bit) (Data bit)
Binary Arithmetic
Binary arithmetic precedes much the same manner as the decimal number addition. The only
difference being that any complete units of 2’s are carried to be added to the next significant
digit.
Rules
A + B = sum + carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Example: solve
1.
2.
12
Computational mathematics………mathematics is a life style……live it…
The excess/extra bits of the sum that cannot fit the expected space are known as overflow.
Note that during arithmetic operations the data to be worked upon are usually held on work
areas of predefined length or capacity and hence in the above examples, the results cannot
fit in any of the spaces that maintained the values to be added.
Subtraction
Rules
0‐0=0
0 ‐ 1 = 1, and borrow 1 from the next more significant bit
1‐0=1
1‐1=0
1011011 − 10010 = 1001001:
Examples
13
Computational mathematics………mathematics is a life style……live it…
The subtraction can also be carried out using the complement and signed magnitude.
Add the overflow digit to the least significant bit of the sum to get the difference.
If the two’s complement method is used, the procedure looks a bit different but the
difference got is the same
14
Computational mathematics………mathematics is a life style……live it…
Complement the digits of the negative number as in 1C method and add a 1 to the least
significant bit of the complemented value. Add the results obtained to the positive number
Hence
= 10 0 1 12
15
Computational mathematics………mathematics is a life style……live it…
Multiplication
0x0=0
0x1=0
1x0=0
1 x 1 = 1, and no carry or borrow bits
Examples
Division
Most computers carry out binary divisions by repetitive subtraction
For example
16
Computational mathematics………mathematics is a life style……live it…
Notes
Binary Number System
-System Digits: 0 and 1
-Bit (short for binary digit): A single binary digit
-LSB (least significant bit): The rightmost bit
-MSB (most significant bit): The leftmost bit
-Upper Byte (or nybble): The right‐hand byte (or nybble) of a pair
-Lower Byte (or nybble): The left‐hand byte (or nybble) of a pair
17
Computational mathematics………mathematics is a life style……live it…
In the coding, when numbers, letters or words are represented by a specific group of
symbols, it is said that the number, letter or word is being encoded. The group of symbols
is called as a code. The digital data is represented, stored and transmitted as group of
binary bits. This group is also called as binary code. The binary code is represented by the
number as well as alphanumeric letter.
Binary codes are used to represent all members among a group of quantities differently
such that every element has a distinct code from any other element.
Weighted Codes
Non-Weighted Codes
Sequential codes
Alphanumeric Codes
Reflective codes
Error Detecting Codes
Error Correcting Codes
18
Computational mathematics………mathematics is a life style……live it…
Weighted codes: These are binary codes which obey positional weight principal. In
weighted codes, each digit is assigned a specific weight according to its position. For
example, in 8421BCD code, 1001 the weights of 1, 0, 0, 1 (from left to right) are 8, 4, 2 and
1 respectively. Examples: 5211 BCD codes, 8421 BCD codes, 2421 BCD codes
Non-weighted codes: These are binary codes which do not obey positional weight principal.
The non-weighted codes are not positionally weighted. In other words, each digit position
within the number is not assigned a fixed value (or weight). Example: Excess-3 and gray
code
Reflective codes: A code is reflective when the code is self-complementing. In other words,
when the code for 9 is the complement we obtain code for 0, 8 for 1, 7 for 2, 6 for 3 and 5
for 4. Examples: 2421BCD, 5421BCD and Excess-3 code
N/B: 8421 BCD code is not a reflective code because it is not self-complementing.
Sequential codes: In sequential codes, each succeeding 'code is one binary number greater
than its preceding code. This property helps in manipulation of data. Examples: 8421 BCD
and Excess-3 are sequential codes.
Alphanumeric codes: Codes used to represent numbers, alphabetic characters, symbols and
various instructions necessary for conveying intelligible information. Examples: ASCII,
EBCDIC, UNICODE are the most-commonly used alphanumeric codes.
Error detection codes: Codes which detect presence of errors in data transmission.
Example: parity codes. N/B: there are other codes which can detect and correct errors. They
are known as error detection and correction codes. Example is hamming codes.
Binary codes
19
Computational mathematics………mathematics is a life style……live it…
Excess-3 code
The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express
decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words
adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as
follows.
Example
20
Computational mathematics………mathematics is a life style……live it…
Gray Code
It is the non-weighted code and it is not arithmetic codes. That means there are no specific
weights assigned to the bit position. It has a very special feature that has only one bit will
change, each time the decimal number is incremented as shown in fig. As only one bit
changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic
code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation.
21
Computational mathematics………mathematics is a life style……live it…
For example:
For example
22
Computational mathematics………mathematics is a life style……live it…
Short form for Binary Coded Decimal. The binary coded decimal (BCD) is a type of
binary code used to represent a given decimal number in an equivalent binary form. Its
main advantage is that it allows easy conversion to decimal digits for printing or display
and faster calculations. BCD is also known as packet decimal and is numbers 0 through 9
converted to four-digit binary. Below is a list of the decimal numbers 0 through 9 and the
binary conversion.
Decimal BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Using this conversion, the number 25, for example, would have a BCD number of 0010
0101. However, in binary, 25 is represented as 11001.
Each digit requires 4 bits and only ten of the values 0 – 9 are used.
Unpacked BCD
Contains only one decimal digit per byte. The digit is stored in the least significant 4 bits.
Packed BCD
Invalid BCD
They are binary numbers which are not allowed in the BCD code. Includes; 1010, 1011,
1100, 1101, 1110, 1111(i.e. between 10 - 15)
23
Computational mathematics………mathematics is a life style……live it…
BCD arithmetic
Addition
BCD addition follows the same rules as binary addition. However, if the addition produces
a carry and/or creates an invalid BCD number, an adjustment is required to correct the sum.
The correction method is to add 6 to the sum in any digit position that has caused an error.
Example
24 + 13 = 37
15 + 9 = 24
19 + 28 = 47
24
Computational mathematics………mathematics is a life style……live it…
NB: Add a 6(0110) to any code which when added exceeds 9(1001)
Subtraction
BCD subtraction follows the same rules as binary subtraction. However, if the subtraction
causes a borrow and/or creates an invalid BCD number, an adjustment is required to correct
the answer. The correction method is to subtract 6 from the difference in any digit position
that has caused an error.
Example
37 - 12 = 25
65 - 19 = 46
25
Computational mathematics………mathematics is a life style……live it…
41 - 18 = 23
Example
51 – 21
51 + 78 = 129
The decimal result is then changed to BCD code to get the result
BCD subtraction using 10’s complement is the same as in case of 9’s complement, the
only difference is that instead of 9’s complement, we have to do 10’s complement of the
subtrahend. In 10’s complement, the carry is ignored.
Example
51 – 21
26
Computational mathematics………mathematics is a life style……live it…
51 + 79 = 130
BCD Multiplication
Multiply the two BCD numbers using the rules for binary multiplication. To adjust the
product divide it by decimal 10, then place the quotient in the most significant byte and the
remainder in the least significant byte (convert the binary answer to unpacked BCD).
Example
BCD Division
Before dividing a BCD number, the division adjustment is made by converting the BCD
numbers to binary. Adjust the two-byte BCD number by multiplying the upper byte by
decimal 10 and adding the product to the lower byte. After the adjustment, divide the two
binary numbers using the rules of binary arithmetic. Finally, convert the binary quotient
into a BCD number if necessary.
27
Computational mathematics………mathematics is a life style……live it…
Example
Exercise
Alphanumeric codes
Alphanumeric codes are sometimes called character codes due to their certain properties.
Now these codes are basically binary codes. We can write alphanumeric data, including
data, letters of the alphabet, numbers, mathematical symbols and punctuation marks by this
code which can be easily understandable and can be processed by the computers. Input
output devices such as keyboards, monitors and mouse can be interfaced using these codes.
12-bit Hollerith code is the better known and perhaps the first effective code in the days of
evolving computers in early days. During this period punch cards were used as the
inputting and outputting data. But nowadays these codes are termed obsolete as many other
modern codes have evolved. The most common alphanumeric codes used these days are
ASCII code, EBCDIC code and Unicode.
Earlier computers were used only for the purpose of calculations i.e. they were only used
as a calculating device. But now computers are not just used for numeric representations,
they are also used to represent information such as names, addresses, item descriptions etc.
Such information is represented using letters and symbols. Computer is a digital system
and can only deal with l's and 0’s. So to deal with letters and symbols they use
alphanumeric codes.
28
Computational mathematics………mathematics is a life style……live it…
i. ASCII code
The full form of ASCII code is American Standard Code for Information Interchange.
It is a seven bit code based on the English alphabet.
In 1967 this code was first published and since then it is being modified and updated.
ASCII code has 128 characters since it has 7 bits. These includes 95 printable characters
including 26 upper and 26 lower case letters, 10 numerals and 33 special characters such as
mathematical symbols etc. It also defines 33 non printable characters. They matched each
symbol with decimal position and each position was converted to binary to get their ASCII
code.
E.g. positions 48 – 57 was taken by decimal 0 – 9
Positions 65 – 90 was taken by upper case A – Z
Positions 97 – 122 was taken by lower case a – z
So if you want to get the ASCII code for 0, convert 48 to binary => 0110000 and ASCII
code for A, convert 65 to binary => 1000001
iii. UNICODE
Unicode is the newest concept in digital coding. In Unicode every number has a unique
character. Leading technological giants have adopted this code for its uniqueness. A part of
the Unicode table is given below.
Error detection
Error means a condition when output information is not same as input information. When
transmission of digital signals takes place between two systems such as a computer, the
transmitted signal is combined with the "Noise". The noise can introduce an error in the
binary bits travelling from one system to other. That means 0 may change to 1 or a 1 may
change to 0.
Whenever a message is transmitted then there are changes that it gets scrambled by noise
or data gets corrupted. When we add some additional data to a given digital message which
can help us to detect if an error occurred during transmission of the message then adding
such data is called an error-detecting code. A simple example of error-detecting code is
parity check.
29
Computational mathematics………mathematics is a life style……live it…
Parity checking is a simple technique for detecting errors. In the MSB of an 8-bits word is
used as the parity bit and the remaining 7 bits are used as data or message bits. The parity
of 8-bits transmitted word can be either even parity or odd parity.
Even parity -- Even parity means the number of 1's in the given word including the parity
bit should be even (2,4,6,....).
Odd parity -- Odd parity means the number of 1's in the given word including the parity
bit should be odd (1,3,5,....).
The parity bit can be set to 0 and 1 depending on the type of the parity required.
For even parity this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is even. Show in the fig. (a).
For odd parity this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is odd. Show in the fig. (b).
30
Computational mathematics………mathematics is a life style……live it…
Parity bit –is an extra bit added to a data bits to make the number of ones in
the data even or odd.
The parity checking at the receiver can detect the presence of an error if the parity of the
receiver signal is different from the expect parity. That means if is known that the parity of
the transmitted signal is always going to be "even" and if the received signal has an odd
parity then the receiver can conclude that the received signal is not correct. If presence of
error is detected then the receiver will ignore the received byte and request for
retransmission of the same byte to the transmitter.
Disadvantages
NB: parity bit is only suitable for detecting errors. It cannot correct any errors as there is
no way to determine which particular bit is corrupted. Data must be discarded entirely and
re-transmitted again from scratch.
31
Computational mathematics………mathematics is a life style……live it…
A logic gate is an electronic circuit that accepts one or more than one inputs and gives out
only one output. Logic gates are the basic building blocks of any digital system. The
relationship between the input and the output is based on certain logic.
AND gate
OR gate
NOT gate
AND Gate
We can mimic the AND gate using the series connection
The bulb only lights when the two switches are on. The bulb will not light when any of the
switches is off.
The operation of AND gate is such that its output is a logic 1 only if all its output are logic
1. Otherwise the output is logic 0.
32
Computational mathematics………mathematics is a life style……live it…
AND gate may have as many inputs as the gate may require. Regardless of the number of
inputs, all the inputs must be logic 1 for the gate to output logic 1. It has n input (n >= 2)
and one output.
Symbol
Truth table
input output
0 0 0
0 1 0
1 0 0
1 1 1
Application
OR Gate
We can mimic the OR gate using the
parallel connection
The bulb lights if any of the switches is closed. The bulb does not light only when all the
switches are off.
33
Computational mathematics………mathematics is a life style……live it…
OR gate outputs logic 1 if any of its output is logic 1. It only outputs logic 0 if all of its
inputs are logic 0.
May have as many inputs as the gate may require but regardless of the number of inputs, if
any of the input is logic 1, the gate outputs logic 1.
Symbol
Truth table
input Output
0 0 0
0 1 1
1 0 1
1 1 1
Application
Car door alarm system. When all the doors are closed, 0000 is applied to the input of the
gate. When one or more gates are open, the output of OR gate is 1, which activates the
alarm.
NOT Gate
Has a single input. It changes logic 0 input to logic 1 output and logic 1 input to logic 0
output. It has n input (n >= 2) and one output.
Symbol
34
Computational mathematics………mathematics is a life style……live it…
Truth table
input Output
0 1
1 0
Application
NOT gate is combined with AND gate and OR gate to come up with two other gates
NAND gate
NOR gate
NAND Gate
A NOT-AND operation is known as NAND operation. The NOT gate negates the output
from the AND gate. Hence NAND gate outputs a 1 if any input is a zero. It has n input (n
>= 2) and one output.
Symbol
35
Computational mathematics………mathematics is a life style……live it…
Truth table
Input output
0 0 1
0 1 1
1 0 1
1 1 0
Application
Device failure alarm system. E.g. fans. When all the fans are working, the input to the
NAND gate is 111 and the output is zero. If any of the fans stops working, the output of
the NAND gate becomes 1, which activates the alarm.
NOR Gate
A NOT-OR operation is known as NOR operation. The NOT gate negates the output from
the NOR gate. Hence NOR gate outputs a 0 if any input is a 1. It has n input (n >= 2) and
one output.
Symbol
Truth table
Input output
0 0 1
0 1 0
1 0 0
1 1 0
36
Computational mathematics………mathematics is a life style……live it…
Application
Exclusive- OR gate
Exclusive-NOR gate
XOR Gate
XOR or Ex-OR gate is a special type of gate. The exclusive-OR gate is abbreviated as EX-
OR gate or sometime as X-OR gate. It has n input (n >= 2) and one output.
XOR gate is sometimes called a parity checker. Parity checkers count the number of ones
and being input and to a circuit and output logic 1 or 0 based on whether the number of
ones is odd or even.
The XOR gate count the number of 1’s at its input and outputs a logic 1 for an odd count
and logic 0 for an even count.
Symbol
Truth
input output
0 0 0
0 1 1
1 0 1
1 1 0
37
Computational mathematics………mathematics is a life style……live it…
XNOR Gate
XNOR gate is a special type of gate. The exclusive-NOR gate is abbreviated as EX-NOR
gate or sometime as X-NOR gate. It has n input (n >= 2) and one output.
XNOR gate is also sometimes called a parity checker. Parity checkers count the number of
ones and being input and to a circuit and output logic 1 or 0 based on whether the number
of ones is odd or even.
The XNOR gate count the number of 1’s at its input and outputs a logic 1 for an even
count and logic 0 for an odd count.
Symbol
Truth
input output
0 0 1
0 1 0
1 0 0
1 1 1
38
Computational mathematics………mathematics is a life style……live it…
OR gate A+B
NOT gate
NAND gate
NOR gate
XOR gate
XNOR gate
Combinational Circuits
Combinational circuit is circuit in which we combine the different gates in the circuit.
Some of the characteristics of combinational circuits are following.
Exercise
(A + B).(A + C)
39
Computational mathematics………mathematics is a life style……live it…
Boolean Algebra
Boolean Algebra is used to analyze and simplify the digital (logic) circuits. It uses only the
binary numbers i.e. 0 and 1. It is also called as Binary Algebra or logical Algebra.
Boolean algebra was invented by George Boole in 1854.
Variable used can have only two values. Binary 1 for HIGH and Binary 0 for
LOW.
Complement of a variable is represented by an over bar (-). Thus complement of
variable B is represented as . Thus if B = 0 then = 1 and B = 1 then = 0.
ORing of the variables is represented by a plus (+) sign between them. For example
ORing of A, B, C is represented as A + B + C.
Logical ANDing of the two or more variable is represented by writing a dot
between them such as A.B.C. Sometime the dot may be omitted like ABC.
Boolean Laws
Addition multiplication
0+0=0 0.0=0
1+0=1 1.0=0
0+1=1 0.1=0
1+1=1 1.1=1
Commutative law
Commutative law states that changing the sequence of the variables does not have any
effect on the output of a logic circuit.
40
Computational mathematics………mathematics is a life style……live it…
Associative law
This law states that the order in which the logic operations are performed is irrelevant as
their effect is the same.
Distributive law
A + (B.C) = (A+B).(A+C)
AND law
These laws use the AND operation. Therefore they are called as AND laws.
OR law
These laws use the OR operation. Therefore they are called as OR laws.
INVERSION law
This law uses the NOT operation. The inversion law states that double inversion of a
variable result in the original variable itself.
De-Morgan’s theorem
Exercise: Simplify
…..property of keiway mining and technology college………compiled by Mr. Mutuku………
41
Computational mathematics………mathematics is a life style……live it…
42
Computational mathematics………mathematics is a life style……live it…
Algebra is a branch of mathematics that uses letters and other symbols instead of numbers.
E.g. x + y = z
QUADRATIC EQUATIONS
ax2+ bx +c = 0
Factorization
Completing square method
Quadratic formula
Graphical method
Factorization method
Quadratic equations are of the form ax2+ bx +c = 0. To solve using factorization method;
Example
43
Computational mathematics………mathematics is a life style……live it…
Solution
= 2x(x + 5) – 3(x + 5) = 0
= (2x - 3)(x + 5) = 0
= 2x – 3 = 0 or x + 5 = 0
= 2x = 3 or x = -5
3
= x = 2 or x = -5
Exercise
Solve by factorization
1. 6x2 – 13x + 6 = 0
2. x2 – 8x – 20 = 0
3. 35x2 – x – 12 = 0
4. 2x2 – 5x + 3 = 0
It is called this because it uses a process called completing the square in the solution
process. So, we should first define just what completing the square is.
x2 + bx
44
Computational mathematics………mathematics is a life style……live it…
This process is called completing the square and if we do all the arithmetic correctly we
can guarantee that the quadratic will factor as a perfect square.
Example
Solve 5x2 – 6x – 2 = 0
Solutions
6 2
x2 - 5 x - 5 = 0
6 2
x2 - x =
5 5
6 6 1 2 2 6 1 2
x2 - 5 x + (− 5 × ) = + (− 5 × )
2 5 2
6 2 36
( x - 10 )2 = +
5 100
3 2 36 19
( x - 5 )2 = + =
5 100 25
3 19
( x - 5 )2 = 25
3 19
x - 5 = ± √ 25
3 19
x = ± √ 25
5
3 ± √19
x= 5
3 + √19 3− √19
x= or x =
5 5
45
Computational mathematics………mathematics is a life style……live it…
Exercise
2x2 – 6x -1 = 0
x2 + 7x – 3 = 0
-7 + 12x – 3x2 = 0
Quadratic formula
𝑏 𝑐 𝑏2
( x + 2𝑎 )2 = - 𝑎 + 4𝑎 2
𝑏 −4𝑎𝑐 + 𝑏2
( x + 2𝑎 )2 = 4𝑎 2
𝑏 −4𝑎𝑐 + 𝑏2
x + 2𝑎 = ± √ 4𝑎 2
𝑏 −4𝑎𝑐 + 𝑏2
x = - 2𝑎 ± √ 4𝑎 2
− 𝑏 ± √𝑏2 −4𝑎𝑐
x = 2𝑎
Example
3x2 – 7x – 1 = 0
46
Computational mathematics………mathematics is a life style……live it…
Solutions
− 𝑏 ± √𝑏2 −4𝑎𝑐
x = 2𝑎
a = 3, b = -7, c = -1
7 ± √49+12
x = 6
7 ± √61
x = 6
7 + √61 7− √61
x = or x =
6 6
Exercise
5x2 + 3x – 7 = 0
4 + 13y + y2
Graphical method
Steps
Example
x2 – 3x + 2 = 0
in the interval -2 ≤ x ≤ 3
47
Computational mathematics………mathematics is a life style……live it…
solution
x -2 -1 0 1 2 3 4 5
y 12 6 2 0 0 2 6 12
14
12
10
0
-4 -2 0 2 4 6
-2
Solution x = 1 or x = 2
Exercise:
1. x2 – 6x + 6 = 0
2. 4x2 – 25x + 28 = 0
MATRIX
Some definitions:
48
Computational mathematics………mathematics is a life style……live it…
Rectangular matrix
A matrix who’s the number of rows is not equal to the number of columns.
Square matrix
Singular matrix
2 1
E.g. ( ) => determinant = (2×1)-(2×1) = 0
2 1
This is a matrix that has a matrix inverse. I.e. its determinant is not 0(zero).
Null matrix
Identity matrix
Is a square matrix with ones on the main diagonal and zeros elsewhere.
Denoted by In or I.
1 0 0
Example: 3 by 3 identity matrix 0 1 0
0 0 1
49
Computational mathematics………mathematics is a life style……live it…
Matrix operations
Addition
𝑎 𝑏 𝑤 𝑥 𝑎+𝑤 𝑏+𝑥
+ 𝑦 𝑧 =
𝑐 𝑑 𝑐+𝑦 𝑑+𝑧
Example:
−2 6 3 7 1 13
3 −5 + −4 3 = −1 −2
4 −8 0 2 4 −6
Subtraction
𝑎 𝑏 𝑤 𝑥 𝑎−𝑤 𝑏−𝑥
- 𝑦 𝑧 =
𝑐 𝑑 𝑐−𝑦 𝑑−𝑧
3 −4 −1 7 4 −11
Example: 0 7 - 4 −2 = −4 9
−4 1 0 2 −4 −1
N/B: To add and subtract a matrix, they must be of the same size.
Multiplication:
scalar multiplication
matrix multiplication.
50
Computational mathematics………mathematics is a life style……live it…
Scalar multiplication
Scalar multiplication is easy. You just take a regular number (called a "scalar") and
multiply it on every entry in the matrix.
𝑎 𝑏 𝑎 𝑏 𝑥𝑎 𝑥𝑏
-let x be a scalar and matrix A = , then xA = x =
𝑐 𝑑 𝑐 𝑑 𝑥𝑐 𝑥𝑑
For the following matrix A, find 2A
1 2
A=
3 4
To do the first scalar multiplication to find 2A, I just multiply a 2 on every entry in the matrix:
1 2 2.1 2.2 2 4
2A = 2. = =
3 4 2.3 2.4 6 8
Matrix multiplication
The number of columns of the 1st matrix must equal the number of rows of the
2nd matrix.
And the result will have the same number of rows as the 1st matrix, and the same
number of columns as the 2nd matrix.
N/B: before you multiply matrices, make sure they are compatible i.e. the number of
elements in the row of the first matrix must be equal to the number of elements in the
column in the second matrix.
Example:
0 3
1 0 −2
A = , B = −2 −1
0 3 −1
0 4
0 3
1 0 −2
Then AB = −2 −1 =
0 3 −1
0 4
51
Computational mathematics………mathematics is a life style……live it…
0+0+0 3+0−8
= [ ]
0−6+0 0−3−4
0 −5]
= [
−6 −7
2 by 2 matrix
𝑤 𝑥
Given matrix A = [ 𝑦 𝑧 ] , then its determinant is obtained as follows;
Det = wz – xy
1 −2
Example. A = [ ] , then det = (1×-7) - (-2×6) = -7 - -12 = -7+12 = 5.
6 −7
3 by 3 matrix
𝑎 𝑏 𝑐
Given matrix A = 𝑑 𝑒 𝑓 , then determinant is obtained as follows;
𝑔 ℎ 𝑖
𝑒 𝑓 𝑑 𝑓 𝑑 𝑒
Det = a| | + b| | + c| |
ℎ 𝑖 𝑔 𝑖 𝑔 ℎ
3 0 2
Example. A = 2 0 −2
0 1 1
0 −2 2 −2 2 0
Then det = 3| | + 0| | + 2| |
1 1 0 1 0 1
= 6 + 0 + 4 = 10
10
52
Computational mathematics………mathematics is a life style……live it…
2 by 2 matrix
Steps:
3 2
Example: find the inverse of the matrix A = [ ]
−1 −2
1 1
1 −2 −2 1 −2 −2
= 𝑑𝑒𝑡 [ ]=- [ ] = [ 2 1 2 3]
1 3 4 1 3 −4 −4
3 by 3 matrix
Co-factor method
Row reduction method
Co-factor method
Steps:
53
Computational mathematics………mathematics is a life style……live it…
3 0 2
A= 2 0 −2
0 1 1
3 0 2
2 0 −2
0 1 1
0 −2 2 −2 2 0
Then det = 3| | + 0| | + 2| |
1 1 0 1 0 1
= 6 + 0 + 4 = 10
10
3 0 2
2 0 −2
0 1 1
0 −2
= | |
1 1
2 −2
= | |
0 1
54
Computational mathematics………mathematics is a life style……live it…
2 0
= | |
0 1
0 2
= | |
1 1
3 2
= | |
0 1
3 0
= | |
0 1
0 2
= | |
0 −2
3 2
= | |
2 −2
55
Computational mathematics………mathematics is a life style……live it…
3 0
= | |
2 0
2 −2 2 0
|0 −2| | | | |
1 1 0 1 0 1
0 2 3 2 3 0
| | | | | |
1 1 0 1 0 1
0 2 3 2 3 0
| | | | | |
0 −2 2 −2 2 0
(0 − −2) (2 − 0) (2 − 0)
= (0 − 2) (3 − 0) (3 − 0)
(0 − 0) (−6 − 4) (0 − 0)
2 2 2
= −2 3 3
0 −10 0
2 2 2 + − + 2 −2 2
−2 3 3 − + − = 2 3 −3
0 −10 0 + − + 0 10 0
56
Computational mathematics………mathematics is a life style……live it…
Step 4: Adjugate(Transpose)
Now transpose the matrix of co-factors. (Transposing means changing the rows to columns
and columns to rows)
2 −2 2 2 2 0
2 3 −3 = −2 3 10
0 10 0 2 −3 0
1
Step 5: Multiply the adjugate by 𝑑𝑒𝑡
2 2 0
1
A-1 = −2 3 10
10
2 −3 0
1 1
0
5 5 0.2 0.2 0
1 3
= −5 10
1 or −0.2 0.3 1
1 3 0.2 −0.3 0
− 0
5 10
An n×n square matrix A is called invertible if there exist matrix X such that;
AX = XA = I (identity)
If that matrix exist, it is unique. We call it the inverse of A and denoted by A -1 = X, so that;
A.A-1 = A-1.A = I
57
Computational mathematics………mathematics is a life style……live it…
Swapping
1 2 3 1 2 3
Eg. 4 5 6 R2 R3 7 8 9
7 8 9 4 5 6
1 2 3 1 2 3
Eg. 4 5 6 R2π 4𝜋 5𝜋 6𝜋
7 8 9 7 8 9
1 2 3 1 2 3
Eg. 4 5 6 R2 = R2 – 4R1 0 −3 −6
7 8 9 7 8 9
Row reduction is a process of using row operations to reduce a matrix to a row reduced
Echelon form.
The first non-zero element (leading coefficient), if any in each row, must be 1.
Each leading coefficient is the only non-zero element in its column.
All the zero rows if any are at the bottom of the matrix
The leading coefficient forms a stair-step pattern from northwest to the southeast.
58
Computational mathematics………mathematics is a life style……live it…
Examples:
1 0 0
0 5 0 No because the leading coefficient in second row is not 1.
0 0 1
1 0 0
0 1 6 No because 1 is not the only non-zero element in that row 3
0 0 1
1 1 −1
1. 2 −1 1
1 1 2
1 −1 2
2. −3 3 −1
2 −1 0
Cramer’s rule
Inverse method
Row reduction method (Gaussian elimination)
59
Computational mathematics………mathematics is a life style……live it…
Cramer’s Rule
Two equations
a1x + b1y = d1
a2x + b2y = d2
𝐷𝑥 𝐷𝑦
x= and y =
𝐷 𝐷
Example
3x + 4y = -14
-2x – 3y = 11
60
Computational mathematics………mathematics is a life style……live it…
Solution
𝐷𝑥 −2
x= = = 2
𝐷 −1
𝐷𝑦 5
y= = -5
𝐷 −1
therefore, x = 2, y = -5
Three equations
a1x + b1 y + c1z = d1
a2x + b2 y + c2z = d2
a3x + b3 y + c3z = d3
61
Computational mathematics………mathematics is a life style……live it…
Therefore
𝐷𝑥 𝐷𝑦 𝐷𝑧
x= , y= , z=
𝐷 𝐷 𝐷
Example
Solve
2x + y + z = 3
x–y–z=0
x + 2y + z = 0
62
Computational mathematics………mathematics is a life style……live it…
Solution
3 −6 9
x = =1 , y = = -2 , z = =3
3 3 3
x = 1, y = -2, z = 3
Exercise
1. Find z
2x + y + z = 1
x – y + 4z = 0
x + 2y – 2z = 3
(ans : z = 2)
63
Computational mathematics………mathematics is a life style……live it…
Inverse method
E.g.
x + 2y = 4
3x – 5y = 1
=(
1
3
2
−5
) ( 𝑦𝑥 ) = ( 14 )
1 2 𝑥
Writing A= (
3 −5
) , X=(𝑦) and B = ( 14 )
We have
AX = B
Therefore, AX = B is the matrix form of the simultaneous equations. The unknown is the
matrix X, since A and B are already known.
64
Computational mathematics………mathematics is a life style……live it…
A-1AX = A-1B
But A-1A = I (identity), hence Ix = x because multiplying any matrix by an identity matrix
of the appropriate size leaves the matrix unchanged. So
X = A-1B
Example
x + 2y = 4
3x – 5y =1
Solution
1 2 x
(
3 −5
)(y)= ( 41 )
1 2
Inverse matrix of A = ( )
3 −5
1 −5 −2
A-1 = ( )
1(−5)−(2×3) −3 1
1 −5 −2
- ( )
11 −3 1
X = A-1B = -
1
11
(
−5
−3
−2
1
) ( 41 )
1
-
11
( −22
−11
) = ( 21 )
X = 2, y = 1
65
Computational mathematics………mathematics is a life style……live it…
Exercise
1. 5x + y = 13
3x + 2y = 5
(ans: x = 3, y = -2)
2. 3x + 2y = -2
x + 4y = 6
(ans: x = -2, y = 2)
NB: It is much more tedious to use the inverse matrix to solve a system of 3 equations
although in principle, the method is the same as for two equations.
Example 1:
x + 5y = 7
−2x – 7y = −5.
Solution:
We carry out the elimination procedure on both the system of equations and the
corresponding augmented matrix, simultaneously. In general only one set of reductions is
necessary, and the latter (dealing with matrices only) is preferable because of the
simplified notation.
x + 5y = 7
−2x – 7y = −5
1 5 7
= ( )
−2 −7 −5
66
Computational mathematics………mathematics is a life style……live it…
x + 5y = 7
3y = 9
1 5 7
= ( )
0 3 9
Multiply Row 2 by 1/3.
x + 5y = 7
y=3
1 5 7
= ( )
0 1 3
Add −5 times Row 2 to Row 1.
X = −8
y=3
1 0 −8
= ( )
0 1 3
Hence x = -8, y = 3
Example 2:
2y + z = −8
x −2y – 3z = 0
−x + y + 2x3z = 3.
Solution:
As before, we carry out reduction on the system of equations and on the augmented matrix
67
Computational mathematics………mathematics is a life style……live it…
2y + z = −8
x – 2y – 3z = 0
−x + y + 2z = 3
0 2 1 −8
=( 1 −2 −3 0)
−1 1 2 3
Swap Row 1 and Row 2.
x – 2y – 3z = 0
2y + z = −8
−x + y + 2z = 3
1 −2 −3 0
=( 0 2 1 −8 )
−1 1 2 3
x – 2y – 3z = 0
2y + z = −8
−y−z=3
1 −2 −3 0
=( 0 2 1 −8 )
0 −1 −1 3
Swap Row 2 and Row 3.
x – 2y – 3z = 0
−y−z=3
2y + z = −8
1 −2 −3 0
=( 0 −1 −1 3)
0 2 1 −8
68
Computational mathematics………mathematics is a life style……live it…
x – 2y – 3z = 0
−y−z=3
− z = −2
1 −2 −3 0
=( 0 −1 −1 3)
0 0 −1 −2
x – 2y = 6
−y =5
− z = −2
1 −2 0 6
(
= 0 −1 0 5)
0 0 −1 −2
x = −4
−y=5
− z = −2
1 0 0 −4
=( 0 −1 0 5)
0 0 −1 −2
69
Computational mathematics………mathematics is a life style……live it…
x = −4
y = −5
z=2
1 0 0 −4
=( 0 1 0 −5)
0 0 1 2
Example 3:
x – 2y – 6z = 12
2x + 4y + 12z = −17
x – 4y – 12z = 22.
Solution:
In this case, we convert the system to its corresponding augmented matrix, perform the
necessary row operations on the matrix alone and then convert back to equations at the end
to identify the solution.
x – 2y – 6z = 12
2x + 4y + 12z = −17
x – 4y – 12z = 22
70
Computational mathematics………mathematics is a life style……live it…
x – 2y6 – 6z = 12
− 2y− 6z = 10
0 = −1
71
Computational mathematics………mathematics is a life style……live it…
Leontief model
There should be enough of each good to meet the demand for it.
There should be no "leftovers", i.e., unused goods.
In a real economy there are tens of thousands of different goods and services, but we can
often simplify matters by combining goods into categories. For example, let us consider a
very simple economy that runs on just 3 different types of output: raw materials, services,
and manufacturing. Raw materials include the output of many different industries,
agriculture and mining to name two. Services include retailing, advertising, transportation,
etc.
Now, the raw materials industry needs some of the output from the other two industries to
do its job. For example, it needs trucking to get its goods to market, and it uses some
manufactured goods (machines.) The raw materials industry even needs some of its own
output to produce its own output - iron ore to make the steel to build the rails that carry ore
from the mines, for example.
Similarly, each of the other two industries requires some amount of output from each of
the three to do its job. All of these requirements can be summarized in the form of a table
such as the following:
The numbers in the table tell how much output from each industry a given industry
requires in order to produce one dollar of its own output. For example, to provide $1
worth of service, the service sector requires $.05 worth of raw materials, $.03 worth of
services, and $.01 worth of manufactured goods.
The information in the table can be more compactly described by dropping the headings.
The result is a 3x3 matrix called the input-output matrix:
72
Computational mathematics………mathematics is a life style……live it…
A second important matrix, the demand matrix, tells how much (in, say, billions of
dollars) of each type of output is demanded by consumers and others outside the economy
("exports".) For example, we might have
For example, the 200 in the second position means that $200 billion worth of services are
demanded by consumers and exporters.
Finally, let X denote the production matrix. It is another column of length 3 that
represents the amounts (in billions of dollars of value) produced by each of the three
industries. We can't fill in the entries of X yet because we don't yet know the levels of
production that will meet the two requirements above. But we can still interpret the
meaning of the matrix product AX: it is also a column of length 3 that represents that part
of the production which is used internally, i.e., by the industries themselves in order to
produce their goods. The difference X - AX = (I - A)X then represents how much of the
output remains to satisfy the external demand. This demand will be exactly met with no
leftover waste provided (I - A)X = D. But we can easily solve this matrix equation for X
thereby obtaining a formula for the required levels of production. In our example we obtain
Thus, the service sector should produce $237.27 billion worth of services, etc, in order for
the economy to "balance".
The overall approach is quite flexible in that small sectors of the economy, even individual
businesses, can be modeled in a similar way - we merely have to regard the rest of the
economy as being part of the "customers and exports" category.
73
Computational mathematics………mathematics is a life style……live it…
NB: In the inter-industry matrix, a column entry typically represents inputs to an industrial
sector, while a row entry represents output from a given sector.
Example:
An economy has the two industries R and S. The current consumption is given by the table
consumption
R S External
Industry R production 50 50 20
Industry S production 60 40 100
Assume the new external demand is 100 units of R and 100 units of S. Determine
Solution:
The total production is 120 units for R and 200 units for S. We obtain
50 50
120 20 100
X= ( ) , B= ( ) , A= (120
60
200
40
) , and B/ = ( )
200 100 100
120 200
The solution is
1 96 30 100 307.3
X/ = (I2 - A)-1B/ = ( ) ( ) = ( )
41 60 70 100 317.0
The new production levels are 307.3 and 317.0 for R and S, respectively.
Cryptography involves encrypting data so that a third party cannot intercept and read the
data.
In the early days of satellite television, the video signals were not encrypted and anyone
with a satellite dish could watch whatever was being shown, so the satellite dish owners
were able to get/receive their satellite feeds for no cost while the cable subscribers had to
pay for the channel. They were losing money.
74
Computational mathematics………mathematics is a life style……live it…
So, they started encrypting the video signals with a system called video cipher. What the
video cipher encryption system did was to convert the signal into digital form, encrypt it,
and send the data over the satellite. If the satellite dish owner had a video cipher box, and
paid for the channel, then the box would descramble (encrypt) the signal and return it to its
original, useful form.
This was done using a key that was invertible. It was very important that the key be
invertible, or there would be no way to return the encrypted data to its original form
Encryption process
Example
Consider the message “RED RUM”. A message is converted into numerical form according
to some scheme. The easiest scheme is to let space = 0, A = 1, B = 2, C = 3, …………., Y =
25, Z = 26. For example the message “RED RUM” would become 18, 5, 4, 0, 18, 21, 13.
This data is placed into matrix form. The size of the matrix depends on the size of the
encryption key. Let’s say that our encryption matrix (encoding matrix) is 2 by 2 matrixes.
Then:
18 5
A=(4 0)
18 21
3 0
There is an invertible matrix which is called encryption matrix or the encoding matrix.
let’s call it B
4 −2
B=( )
−1 3
The encrypted data is then multiplied by our encoding matrix. The result of this
multiplication is the matrix containing the encrypted data.
67 −21
AB = (16 −8 )
51 27
52 −26
…..property of keiway mining and technology college………compiled by Mr. Mutuku………
75
Computational mathematics………mathematics is a life style……live it…
The message that would be passed on to the other person is the stream of numbers 67, -21,
16, -8, 51, 27, 52, -26.
Decryption process
1. Place the encrypted stream of numbers that represented an encrypted message into a
matrix
2. Multiply by the decoding matrix. The decoding matrix is the inverse of the encoding
matrix
3. Convert the matrix into a stream of numbers
4. Convert the numbers into the text of the original message
Example
The message you need to decipher is the encrypted data stream 67, -21, 16, -8, 51, 27, 52, -
26.
NB: The encryption matrix is not transmitted. It is known by the receiving party so that they
can decrypt the message. Other times, the inverse is known by the receiving party. The
encryption matrix cannot be sent with the data; otherwise, anyone could grab the data and
decode the information. Also, by not having the decoding matrix, someone intercepting the
message doesn’t know what size of matrix to use.
The receiving end gets the encrypted message and places it into matrix form.
67 −21
X = (16 −8 )
51 27
52 −26
The receiver must calculate the inverse of the encrypted matrix. this would be the decryption
matrix or the decoding matrix.
0.3 0.2
B-1 = ( )
0.1 0.4
The receiver then multiplies the encrypted data by the inverse of the encryption matrix.
18 5
A = XB-1 = (4 0)
18 21
3 0
The receiver then takes the matrix and breaks it apart into values 18, 5, 4, 0, 18, 21, 13, 0
and converts each of those into a character according to numbering scheme. 18 = R, 5 = E,
4 = D, 0 = space, 18 = R, 21 = U, 13 = M, 0 = space = “RED RUM”
76
Computational mathematics………mathematics is a life style……live it…
Exercise
−1 5 −1
Using encryption matrix B = (−2 11 7) encrypt message “I LOVE MONICA”.
1 −5 2
Write the stream of numbers that will be send.
Storage of information
77
Computational mathematics………mathematics is a life style……live it…
A set is a collection of objects. Objects in a set are called elements. A set is denoted by
capital letters and the elements by small letters.
E.g. A {a,b,c}
If a is an element of A, we denote as a∈ A.
A set is called finite if it contains finite number of elements. If a set is not finite, it is
called infinite.
Cardinality
Types of sets
1) subset
2) Equal sets
Two sets, A and B, are equal, denoted A=B, if and only if all element in A
belongs to the set B and every element in B belongs to set A, i.e.
A ⊆ B and A ⊇ B.
3) Proper subset
equal A.
4) Empty set
78
Computational mathematics………mathematics is a life style……live it…
5) Complementary set
6) Universal set
Venn diagram
Union
The union of sets A and B, denoted A ∪ B, is the set containing all elements in either A or
B or both. i.e.
A ∪ B = {γ : γ ∈ A or γ ∈ B}.
79
Computational mathematics………mathematics is a life style……live it…
Example
A ∩ B = {1, 3, 4, 5, 6, 7, 8}
Intersection
The intersection of sets A and B, denoted A ∩ B, is the set containing all elements in both
A and B. i.e.
A ∩ B = {γ : γ ∈ A and γ ∈ B}.
Example
A∩B = {3, 5}
Difference
The difference of A and B is denoted as A\B i.e. elements in A and not in B. Also B\A are
elements in B and not in A. The diagrams below shows the shaded region for A − B and
B−A
80
Computational mathematics………mathematics is a life style……live it…
Example
Complement of a set
Let A be a set and U be the universal set. Then A/ (called the complement of A and
pronounced “A prime”) denotes the set of all elements in U which do not belong to A.
The graph below shows the shaded region for the complement of set A
81
Computational mathematics………mathematics is a life style……live it…
Example
Let U = {a, b, c, d, e, f}, A = {a, c}, B = {b, c, f}, C = {b, d, e, f}. Then
B∪C = {b, c, d, e, f}
A∩ (B∪C) = {c}
A/ = {b, d, e, f} = C
Exercise
82
Computational mathematics………mathematics is a life style……live it…
EXAMPLE
A travel agent surveyed 100 people to find out how many of them had visited the cities of
Melbourne and Brisbane. Thirty-one people had visited Melbourne, 26 people had been to
Brisbane, and 12 people had visited both cities. Draw a Venn diagram to find the number
of people who had visited:
i. Melbourne or Brisbane
ii. Brisbane but not Melbourne
iii. only one of the two cities
iv. Neither city.
SOLUTION
Let M be the set of people who had visited Melbourne, and let B be the set of people who
had visited Brisbane. Let the universal set E be the set of people surveyed.
83
Computational mathematics………mathematics is a life style……live it…
84
Computational mathematics………mathematics is a life style……live it…
Rule of sum
States that if there are n ways to do task 1, and m ways to do task 2, and the two tasks cannot
be performed at the same time, then there are n+m ways to do one of the two tasks. We must
make one choice OR a second choice.
Example 1:
There are 18 math majors and 325 CS majors. How many ways are there to pick one math
major or one CS major?
Solution
Example 2:
How many strings of 4 decimal digits have exactly three digits that are 9s?
Solution
85
Computational mathematics………mathematics is a life style……live it…
Thus, we use the sum rule. For each case, there are 9 possibilities for the non-9 digit (any
number other than 9)
Example
S = {a,b,c}
Solution
Find: |A∪B|
Answer:
|A∪B| = 9 + 9 - 3 = 15
States that if there are n ways to do task 1, and m ways to do task 2, then there are nm ways
of to do both tasks in sequence. We must make one choice AND choice.
Example 1
There are 18 math major and 325 CS majors. How many ways are there to pick one math
major and one CS major?
86
Computational mathematics………mathematics is a life style……live it…
Solution
Example 2
Solution
a. We want to choose a digit, then another that is not the same, then another…..
The first digit: 10 possibilities
Second digit: 9 possibilities
Third digit: 8 possibilities
Fourth digit: 7 possibilities
Total = 10 × 9 × 8 × 7 = 5040
Total = 10 × 10 × 10 × 5 = 5000
Example 3
Consider a wedding picture of 6 people. There are 10, including the bride and the groom.
How many possibilities are there if the bride must be in the picture?
Solution
Place the bride AND then place the rest of the party
87
Computational mathematics………mathematics is a life style……live it…
Next, place the other five people via the product rule. There are 9 people to choose for the
second, 8 for the third, 7 for the fourth, 6 for the fifth and 5 for the sixth.
Total = 9 × 8 × 7 × 6 × 5 = 15120
Example 1:
How many 3-character words with 1st character from A, 2nd from B, 3rd from C?
Example 2:
How many ways to form 3-person committee with one member from each party?
Answer: 3 × 2 × 4 = 24
When counting the possibilities, we cannot include a given outcome more than once.
Inclusion/Exclusion Principle
To calculate |A1∪A2∪…∪An|,
88
Computational mathematics………mathematics is a life style……live it…
Example:
A = divisible by 2
B = divisible by 3
C = divisible by 5
Find: |A∪B∪C|
|B∩C| = |{15,30,…,990}| = 66
|A∩B∩C| = |{30,60,…,990}| = 33
Choose r times from a set of n items with replacement and order matters. Drawing with
replacement (sequence can repeat items):
If there are n distinct objects and we draw r times. Each drawing has n distinct
possibilities. If order matters, then by the product rule we have n x n x ... x n possibilities =
nr .
A permutation is the choice of r things from a set of n things where the order matters.
89
Computational mathematics………mathematics is a life style……live it…
Example 1:
Create a sequence of 10 numbers by rolling a die 10 times. How many possible sequences?
Answer: 610
Example 2:
S = {0,1,…,7}
Answer: 85
Choose r times from a set of n items with replacement and order does not matter.
A combination is the choice of r things from a set of n things where order does not matter.
Example:
You have 4 different kinds of cookies. How many different ways can 6 cookies be chosen?
Method: Choose 6 times from a set of 4 with replacement and order does not matter.
9×8×7
Answer: C(4+6-1,6) = C(9,6) = = 84
3×2×1
Choose r times from a set of n items without replacement and order matters. If we do not
have replacement but order matters:
90
Computational mathematics………mathematics is a life style……live it…
Then first drawing has n possibilities; the second drawing has (n-1), the third has (n-2), etc.
By the product rule we have: n x (n-1) x (n-2) x ... x (n-r+1)
𝑛!
=
(𝑛−𝑟)!
Example 1:
Six CD's with 57 songs. CD player can be programmed to play any 20 songs in any order.
How many ways can 20 different songs be played?
Example 2:
Given n integers x1, x2,…, xn , all distinct. How many sorted arrangements are possible
(i.e. how many permutations of x1 … x n?)
Example 3:
S = {a,b,c,d,e,f}
Choose r times from a set of n items without replacement and order doesn't matter. If order
does not count and there is no replacement, then we must determine how many of the
91
Computational mathematics………mathematics is a life style……live it…
permutations are the same objects but only differ in order. That is: In how many orders can
n distinct objects be arranged?
𝑛!
P(n,n) = = n!
0!
Therefore, if order does not matter and we do not have replacement, the number of
possibilities for n objects taken r at a time is
𝑝(𝑛,𝑟)! 𝑛!
=
𝑝(𝑟,𝑟)! (𝑛−𝑟)!𝑟!
Example
0! = 1
92
Computational mathematics………mathematics is a life style……live it…
Example on permutation
Examples 1
5 people are to be seated in a row. How many sitting arrangements are possible?
Solution: 5! = 120
Example 2
5 letter words are formed from the letters of the word “TIEGRUOK”. How many these words
have no repeated letters?
8! 8!
Solution: 8P5 = (8−5)!
= 3! = 6720
Example 3
Solution:
5! 5!
5P3 = (5−3)! = 2! = 60
b. 5 5 5 = 125
Example 4
How many arrangements of the letters of the word “BEGIN” are there which starts with a
vowel without repetition?
Solution: there are only 2 vowels. So first position can only be filled with 2 ways
So number of ways 2 × 4 × 3 × 2 × 1 = 48
Examples on Combinations
Example 1
How many numbers between 10 and 300 can be made from the digits 1, 2, 3 if
93
Computational mathematics………mathematics is a life style……live it…
Solution:
Total = 6 + 4 = 10
Example 2
Solution: 8C4 = 70
Example 3
A mixed hockey team has 6 women and 5 men. A team is to be chosen from 7 men and 9
women. In how many ways can this be done?
The number of arrangements of n objects taken all at a time where r1 are alike of one kind,
𝑛!
r2 alike of 2nd type, r3 alike of the 3rd type and so on is
𝑟1! 𝑟2! 𝑟3!……….
Example
11!
= = 34650
4! × 4! × 2!
94
Computational mathematics………mathematics is a life style……live it…
(a + b)0 = 1
(a + b)1 = a + b
(a + b)2 = a2 + 2ab + b2
Clearly, doing this by direct multiplication gets quite tedious and can be rather difficult for
larger powers or more complicated expressions.
Pascal's Triangle
We note that the coefficients (the numbers in front of each term) follow a pattern. [This
was noticed long before Pascal, by the Chinese.]
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
You can use this pattern to form the coefficients, rather than multiply everything out as we
did above.
We use the binomial theorem to help us expand binomials to any given power without
direct multiplication. As we have seen, multiplication can be time-consuming or even not
possible in some cases.
95
Computational mathematics………mathematics is a life style……live it…
Example 1
-factorial values
(a) 3!=(3)(2)(1)=6
(b) 5!=(5)(4)(3)(2)(1)=120
(c) 2!4!=(2)(1)(4)(3)(2)(1)=12
96
Computational mathematics………mathematics is a life style……live it…
Example 1
Expand (x + 2)5
Solution
Example 2
1
Obtain the expansion of (3x - 3)4 in decreasing powers of x
1 1 1 1 1
= 4C0(3x)4( - )0 + 4C1(3x)3( - )1 + 4C2(3x)2( - )2 + 4C3(3x)1( - )3 + 4C4(3x)0( - )4
3 3 3 3 3
1 1 1 1
= 1.81x4.1 + 4.27x3. - 3 + 6.9x2. + 4.3x. - 27 + 1.1. 81
9
4 1
= 81x4 – 36x3 + 6x2 - 9 x + 81
Exercise
1
3. (1 + 2x)12 hence solve (1.0511)12 correct to 4 d.p
In general,
𝑛(𝑛−1)
(a + b)n = an + nan-1 b + 2!
an-2b2 + 𝑛(𝑛−1)(𝑛−2)
3!
an-3b3 + 𝑛(𝑛−1)(𝑛−2)(𝑛−3)
4!
an-4b4 ……
97
Computational mathematics………mathematics is a life style……live it…
𝑥 𝑥 𝑥
(a + x)n = [a(1 + )]n = an(1 + )n if | |<1
𝑎 𝑎 𝑎
Exercise
1.
Expand (1 + x)1/2
2.
Expand (1 – 2x)-3
98
Computational mathematics………mathematics is a life style……live it…
If the rule for a relation between two variables is given, then the graph of the relation can
be drawn by constructing a table of values.
To plot a straight line graph we need to find the coordinates of at least two points that fit
the rule.
Example 6
Solution:
In order to find the y values for the table, substitute each x value into the rule y = 3x + 2
When x = 0, y = 3(0) + 2 = 2
When x = 1, y = 3(1) + 2 = 5
When x = 2, y = 3(2) + 2 = 8
99
Computational mathematics………mathematics is a life style……live it…
Draw a Cartesian plane and plot the points. Then join the points with a ruler to obtain a
straight line graph.
9
8
7
6
5
4
3
2
1
0
-3 -2 -1 0 1 2 3
Example 7
Solution:
When x = 0, y = -2(0) + 4 = 4
When x = 1, y = -2(1) + 4 = 2
When x = 2, y = -2(2) + 4 = 0
When x = 3, y = -2(3) + 4 = -2
When x = 4, y = -2(4) + 4 = -4
100
Computational mathematics………mathematics is a life style……live it…
10
0
-3 -2 -1 0 1 2 3 4 5
-2
-4
-6
Making interpretations
Exercise
101
Computational mathematics………mathematics is a life style……live it…
Find
i. The gradient
ii. The co-ordinates of the y-intercept and the x-intercept
Pie charts
Bar charts
Pictogram
Histogram
Pie charts
Pie charts are a visual way of displaying how the total data are distributed between
different categories. It shows the proportional distribution of visitors between different
types of tourist attractions. Similar uses of a pie chart would be to show the percentage of
the total votes received by each party in an election. Pie charts should only be used for
displaying nominal data (i.e. data that are classed into different categories). They are
generally best for showing information grouped into a small number of categories and are a
graphical way of displaying data that might otherwise be presented as a simple table.
Now you need to figure out how many degrees for each "pie slice" (correctly called a
sector).
102
Computational mathematics………mathematics is a life style……live it…
SciFi
Comedy
Drama
Action
Romance
Bar charts
A Bar Graph (also called Bar Chart) is a graphical display of data using bars of different
heights. Bar charts are one of the most commonly used types of graph and are used to
display and compare the number, frequency or other measure (e.g. mean) for different
discrete categories or groups. The graph is constructed such that the heights or lengths of
the different bars are proportional to the size of the category they represent. Since the x-
axis (the horizontal axis) represents the different categories it has no scale. The y-axis (the
vertical axis) does have a scale and this indicates the units of measurement. The bars can
be drawn either vertically or horizontally depending upon the number of categories and
length or complexity of the category labels. There are various ways in which bar charts can
be constructed and this makes them a very flexible chart type. For example, if there is more
than one set of values for each category then grouped or component bar charts can be used
to display the data. Further details about each of these different types of bar chart can be
found in the associated study guide Bar Charts. E.g. the information below shows different
means of transport and the number of people who use each means.
103
Computational mathematics………mathematics is a life style……live it…
0
Comedy Action Romance Drama SciFi
Bar Graphs are good when your data is in categories (such as "Comedy", "Drama", etc).
But when you have continuous data (such as a person's height) then use a Histogram.
It is best to leave gaps between the bars of a Bar Graph, so it doesn't look like a Histogram.
Histograms
A Histogram is a graphical display of data using bars of different heights. Histograms are a
special form of bar chart where the data represent continuous rather than discrete
categories. For example a histogram could be used to present details of the average number
of hours exercise carried out by people of different ages because age is a continuous rather
than a discrete category. However, because a continuous category may have a large
number of possible values the data are often grouped to reduce the number of data points.
For example, instead of drawing a bar for each individual age between 0 and 65, the data
could be grouped into a series of continuous age ranges such as 16-24, 25-34, 35-44 etc.
Unlike a bar chart, in a histogram both the x- and y-axes have a scale. This means that it is
the area of the bar that is proportional to the size of the category represented and not just its
height.
104
Computational mathematics………mathematics is a life style……live it…
Histograms are a great way to show results of continuous data, such as:
weight
height
how much time
etc.
Pictogram
105
Computational mathematics………mathematics is a life style……live it…
Probability deals with likelihood of an event to occur. We use probability to predict what is
likely to happen in future. Sometimes the past experience is used to determine probability.
Generally, probability is the numerical measure of the chance.
Experimental probability
Is the probability which can be determined through experience or from experiment. E.g. if a
fair coin is tossed 10 times and the number of heads and tails showing up were recorded as
follows, 3 heads and 7 tails, the experimental probability of obtaining head is;
3
P(H) = 10
7
P(T) = 10
From this example, every toss is called a trial and possible results of a trial are called an
outcome.
𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑜𝑢𝑡𝑐𝑜𝑚𝑒𝑠
Therefore, experimental probability = 𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑡𝑟𝑖𝑎𝑙𝑠
Sample space
Is the set of all possible outcomes in an experiment. Example is a single toss of a coin in
which there are two possible outcomes with either the head or the tail.
Event
106
Computational mathematics………mathematics is a life style……live it…
NB: for any event A, the probability of A is greater than or equal to zero and the probability
of the sample space is 1. i.e. 0 ≤ p(A) ≤ 1.
Examples 1
Two coins are spun together. What is the probability that at least one head appears
Solution
3
P(A) = 4
Example 2
After tossing a coin 10 times, it was found that that the probability of getting a head is 0.4.
what is the probability of getting a tail in this experiment.
Solution
Exercise
107
Computational mathematics………mathematics is a life style……live it…
Types of events
Independent Events
Two events, A and B are said to be independent if the occurrence of A does not influence
the occurrence of B.
Dependent Events
Two events, A and B are dependent if the occurrence of A influences the occurrence of B.
For example, two dependent events would be drawing two cards (one at a time) without
returning them to the deck.
Two events, A and B, are said to be mutually exclusive when occurrence of A prevents the
occurrence of B. i.e. they cannot appear at the same time. They don´t have an element in
common.
For example, tossing a coin. Getting the head prevents the tail from showing.
A∩B=ø and ᴗ
A B = S (sample space)
ᴗ
A B = P(A) + P(B)
Elementary Event
An elementary event is an event that has only one of the elements which forms the sample
space.
Compound Event
A compound event is an event that contains two or more elements of the sample space.
For example, if a die is thrown, a compound event would be an even number or a multiple
of 3.
108
Computational mathematics………mathematics is a life style……live it…
Sure Event
The sure event is an event that contains all the elements of the sample space, S. It has a
probability of 1
Impossible Event
The impossible event is an event that cannot occur, i.e. does not have an element. It has a
probability of 0.
Complementary Event
The complementary event of A is another event that is realized when A is not realized. It is
denoted by or A'.
For example, the complementary event of obtaining an even number when rolling a die is
obtaining an odd number.
Exhaustive events
A set of events, where the union of all the experiments in the space is the complete space
itself, is called Exhaustive Events.
Types of probability
Rules of probability
0 ≤ P(A) ≤ 1
109
Computational mathematics………mathematics is a life style……live it…
Example: A bag contains 5 red marbles, 3 blue marbles, and 2 green marbles.
5 3 2
P(red) + P(blue) + P(green) = 1 => 1
10 10 10
3. The sum of the probability of an event occurring and it not occurring is 1. P(A) +
P(A not occurring) = 1 or P(not A) = 1 - P(A).
Example: A bag contains 3 red marbles, 5 blue marbles, and 2 green marbles.
5 7
P (red) + P(not red) = 1 => P (red) = 10 and P (not red) 10
4. If two events A and B are independent (this means that the occurrence of A has no
impact at all on whether B occurs and vice versa), then the probability of A and B
occurring is the product of their individual probabilities.
Example: roll a die and flip a coin. P(head and a roll 3) = P(H) and P(3)
1 1 1
2 6 12
5. If two events A and B are mutually exclusive (meaning A cannot occur at the same
time as B occurs), then the probability of either A or B occurring is the sum of their
individual probabilities. P(A or B) = P(A) + P(B)
Example: A bag contains 5 red marbles, 3 blue marbles, and 2 green marbles.
5 2 7
P(red or green) = P(red) + P(green)
10 10 10
110
Computational mathematics………mathematics is a life style……live it…
6. If two events A and B are not mutually exclusive (meaning it is possible that A and
B occur at the same time), then the probability of either A or B occurring is the sum
of their individual probabilities minus the probability of both A and B occurring.
P(A or B) = P(A) + P(B) – P(A and B)
Example: There are 20 people in the room: 12 girls (5 with blond hair and 7 with
brown hair) and 8 boys (4 with blond hair and 4 with brown hair). There are a total
of 9 blonds and 11 with brown hair. One person from the group is chosen
randomly. P(girl or blond) = P(girl) + P(blond) – P(girl and blond)
12 9 5 16
20 20 20 20
7. The probability of at least one event occurring out of multiple events is equal to one
minus the probability of none of the events occurring. P(at least one) = 1 – P(none)
Example: roll a die 4 times. What is the probability of getting at least one head on
1 1 1 1
the 4 rolls. P(at least one H) = 1 – P(no H) = 1 – P (TTTT) = 1 -
2 2 2 2
1 15
1-
16 16
Example: There are 20 people in the room: 12 girls (5 with blond hair and 7 with
brown hair) and 8 boys (4 with blond hair and 4 with brown hair). P (girl with
7 12
brown hair) ≤ P(girl)
20 20
Rule of Multiplication
The probability that Events A and B both occur is equal to the probability that Event A
occurs times the probability that Event B occurs, given that A has occurred.
111
Computational mathematics………mathematics is a life style……live it…
Example
An urn contains 6 red marbles and 4 black marbles. Two marbles are drawn without
replacement from the urn. What is the probability that both of the marbles are black?
Solution: Let A = the event that the first marble is black; and let B = the event that the
second marble is black. We know the following:
In the beginning, there are 10 marbles in the urn, 4 of which are black. Therefore,
P(A) = 4/10.
After the first selection, there are 9 marbles in the urn, 3 of which are black.
Therefore, P(B|A) = 3/9.
Rule of Addition
The rule of addition applies to the following situation. We have two events, and we want to
know the probability that either event occurs.
Then the probability that Event A or Event B occurs is equal to the probability that Event
A occurs plus the probability that Event B occurs minus the probability that both Events A
and B occur.
Note: Invoking the fact that P(A ∩ B) = P( A ) × P( B | A ), the Addition Rule can also be
expressed as
Example
A student goes to the library. The probability that she checks out (a) a work of fiction is
0.40, (b) a work of non-fiction is 0.30, and (c) both fiction and non-fiction is 0.20. What is
the probability that the student checks out a work of fiction, non-fiction, or both?
Solution: Let F = the event that the student checks out fiction; and let N = the event that the
student checks out non-fiction. Then, based on the rule of addition:
112
Computational mathematics………mathematics is a life style……live it…
Exercise
1. A number is selected randomly from integers between 20 and 34 inclusive. Find the
probability that
i. Its second digit is greater than its first digit
ii. It is divisible by 4
iii. Its second digit is greater than its first digit and it is divisible by 4
iv. Its second digit is greater than its first digit or it is divisible by 4
2. Two fair dices labeled 1- 6, are rolled together. Let capital A be the product of the
two numbers showing up is greater than 21. . Let capital B be the product is
divisible by 4
Find the probability of
i. P(A)
ii. P(B)
iii. P(A∩B)
iv. P(A∩B)
Conditional probability
If A and B are two events in the sample space that S such that probability of A and B i.e.
P(A) and P(B), is not equal to 0 (zero), then the conditional probability of A given B is
defined as:
𝑃(𝐴∩𝐵)
P(A/B) =
𝑃(𝐵)
I.e. the probability of event A given that event B has already taken occurred.
𝑃(𝐵∩𝐴)
P(B/A) =
𝑃(𝐴)
Example
Two political parties A and B have 40 and 120 members of parliament respectively and are
such that 20% of party A MP’s is liars while 30% of party B MP’s are also liars. An MP is
picked at random and asked his/her party’s policy. Find the probability that
113
Computational mathematics………mathematics is a life style……live it…
i. He or she lies
ii. Given that he/she lies, find the probability that he/she comes from party A
Solution
But
𝑃(𝐿∩𝐴)
P(L/A) = = > 𝑃(𝐿 ∩ 𝐴) = P(L/A) × 𝑃(𝐴)
𝑃(𝐴)
𝑃(𝐿∩𝐵)
P(L/B) = => 𝑃(𝐿 ∩ 𝐵) = P(L/B) × 𝑃(𝐵)
𝑃(𝐵)
0.2 × 0.25
𝑜.275
0.1818
114
Computational mathematics………mathematics is a life style……live it…
Remarks
For events A and B which are independent, the probability P(A) = P(A/B)
BAYE’S THEOREM
Suppose that B1, B2, B3,………………..Bk are mutually exclusive events and constitutes a
partition of a sample space S and P(Bi) ≠ 0 for i = 1, 2, 3, …………………k. Let A be an
event that can only occur in conjunction with only one of the events B1, B2, B3, ….Bk.
Then the probability of Bi given A is given by
𝑃(𝐴/𝐵𝑖) × 𝑃(𝐵𝑖)
P(Bi/A) =
𝑃(𝐴/𝐵1)𝑃(𝐵1)+𝑃(𝐴/𝐵2)𝑃(𝐵2)+𝑃(𝐴/𝐵3)𝑃(𝐵3)+⋯𝑃(𝐴/𝐵𝑘)𝑃(𝐵𝑘)
𝑃(𝐴/𝐵𝑖) × 𝑃(𝐵𝑖)
= ∑ 𝑃(𝐴/𝐵𝑖) × 𝑃(𝐵𝑖)
Example
A consulting firm rents cars from 3 rental agencies. 60% from agency 1, 30% from agency
2 and 10% from agency 3. If 9% of cars from agency 1 needs tune-up, 20% of agency 2
need tune-up and 6% of agency 3 need tune-up. What is the probability that
Solution
115
Computational mathematics………mathematics is a life style……live it…
𝑃(𝐴∩𝐵𝑖)
P(A/Bi) = But 𝑃(𝐴 ∩ 𝐵𝑖) = P(A/Bi) × P(Bi)
𝑃(𝐵𝑖)
i. We need
0.12
𝑃(𝐴/𝐵2) × 𝑃(𝐵2)
ii. P(B2/A) =
𝑃(𝐴/𝐵1)𝑃(𝐵1)+𝑃(𝐴/𝐵2)𝑃(𝐵2)+𝑃(𝐴/𝐵3)𝑃(𝐵3)
0.2 ×0.3
=
0.12
= 0.5
A Tree diagram
It is a useful aid/tool in solving problem where the probabilities involve two or more sets
of compound events. E.g. if a coin is tossed 3 times, the tree diagram below show all the
possible outcome
116
Computational mathematics………mathematics is a life style……live it…
Example
An Aids diagnostic test is such that it gives positive results with a probability of 0.95 if the
person has the Aids virus and it gives positive results with probability of 0.01 if the person
has no Aids virus. Given that 30% of the population are known to have Aids, calculate the
probability that a randomly chosen person
i. Tests positive
ii. Has Aids given that he/she tested positive
Solution
P(A) = 0.3, P(B) = 0.7, P(P/A) = 0.95, P(P/B) = 0.01, P(N/A) = 0.05, P(N/B) = 0.99
117
Computational mathematics………mathematics is a life style……live it…
Test positive
P(AP) or P(BP)
0.976
Exercise
1. The probability that Ann catches the school bus is 0.57. If she catches the school
bus, the probability that she is late for school assembly is 0.12. If she misses the
school bus, the probability that she will be late for school assembly is 0.73. Find
the probability that in one day
i. She is late for the school assembly
ii. Given that she was late, find the probability that she missed the bus
2
2. The probability that horse A wins a race against horse B is . If the two horses run
5
3 races in succession, what is the probability that
i. Horse B wins all the races
ii. Horse A wins only one race
iii. Horse A wins at least one race
iv. Horse B wins more races than horse A
118
Computational mathematics………mathematics is a life style……live it…
Use of tree diagram may be tedious when the tree grows beyond 4 stages. Under such a
situation, we can make use of binomial formula so long as the following conditions are
satisfied
i. Each trial in the experiment has only 2 outcomes i.e. success and failure with
constant probabilities:
P and 1- P = Q respectively in each trial
𝑛!
=> nCx = and this is binomial formula
𝑥!(𝑛−𝑥)!
Example
i. Exactly 4 heads
ii. At least 6 heads
iii. At least 1 head
Solution
1 1 8 1 35
i. P(4H) = 8C4(2)4 (2)4 = ( )8 =
4!(8−4)! 2 128
35
128
119
Computational mathematics………mathematics is a life style……live it…
37
=
256
255
=
256
120
Computational mathematics………mathematics is a life style……live it…
Types of data
a. Primary data- are those which are collected a fresh and for the first time and thus
happen to be original in character
b. Secondary data – are those which have been collected by someone else and which
have already been passed through the statistical process
Data sources
Primary source
Secondary source
1. interview
2. observation
3. action research
4. case studies
5. life histories
6. questionnaires
7. ethnographic research
8. longitudinal studies
1. Previous research
2. Official statistics
3. Mass media products
4. Diaries
5. Letters
6. Government reports
7. Web information
8. Historical data and information
121
Computational mathematics………mathematics is a life style……live it…
1. Observations
Advantages
Disadvantages
1. Observer Effect - the presence of an observer in some way influences the behavior
of those being observed.
2. Observer Bias – is that it is susceptible to observer bias – subjective bias on the
part of the observer
3. Time consuming - observation is that it can be very time consuming and resource
intensive.
122
Computational mathematics………mathematics is a life style……live it…
2. Questionnaires
Is a set of printed or written questions with a choice of answers, devised for the
purposes of a survey or statistical study.
Questionnaire Design
Advantages
Disadvantages
1. Survey respondents may not complete the survey resulting in low response rates
2. Items may not have the same meaning to all respondents
3. Size and diversity of sample will be limited by people’s ability to read
4. Given lack of contact with respondent, never know who really completed the
survey
5. Unable to probe for additional details
6. Good survey questions are hard to write and they take considerable time to develop
and hone
123
Computational mathematics………mathematics is a life style……live it…
3. Interviews
Advantages
Disadvantages
1. Time consuming
2. Expensive compared to other data collection methods
3. May seem intrusive to the respondents
4. Susceptible to interview bias
Geographical Classification:
In this type of classification, data is classified according to area or region. For example,
when we consider production of wheat State wise, this would be called geographical
classification. The listing of individual entries is generally done in an alphabetical order or
according to size to emphasize the importance of a particular area or region.
Chronological Classification:
When the data is classified according to the time of the occurrence, it is known as
chronological classification.
124
Computational mathematics………mathematics is a life style……live it…
other not possessing it. For example, we may classify population on the basis of
employment, i.e., the employed and the unemployed. Similarly we can have manifold
classification when an attribute is divided so as to form several classes. For example, the
attribute education can have different classes such as primary, middle, higher secondary,
university, etc.
Quantitative Classification:
This is where numbers are used to record data. For example, the employees of a company
may be classified according to their monthly salaries. Since quantitative data is
characterized by different numerical values, the data represents the values of a variable.
Quantitative data may be further classified into one or two types: discrete or continuous.
The term discrete data refers to quantitative data that takes whole numbers. For example,
the number of employees in an organization or the number of machines in a factory is
examples of discrete data. Continuous data can take all values of the variable, i.e. both
whole and fraction numbers. For example, the data relating to weight, distance, and
volume are examples of continuous data.
Data tabulation
The process of placing classified data into tabular form is known as tabulation. It may be
simple, double or complex depending upon the type of classification.
Parts of a table
A table is a symmetric arrangement of statistical data in rows and columns. Rows are
horizontal arrangements whereas columns are vertical arrangements.
Types of tabulation
125
Computational mathematics………mathematics is a life style……live it…
Complex Tabulation:
When the data are tabulated according to many characteristics, it is said to be complex
tabulation.
For Example: Tabulation of data on population of world classified by two characteristics
like Religion, Sex and Literacy etc…is example of complex tabulation.
Sampling
Sampling is concerned with the selection of a subset of individuals from within a statistical
population to estimate characteristics of the whole population. A sample is “a smaller (but
hopefully representative) collection of units from a population used to determine truths
about that population”
Why sample?
Types of Samples
Probability (Random) Samples
Non-Probability Samples
Convenience sample
Purposive sample
Quota
126
Computational mathematics………mathematics is a life style……live it…
Probability sampling
A probability sampling scheme is one in which every unit in the population has a chance
(greater than zero) of being selected in the sample, and this probability can be accurately
determined.
When every element in the population does have the same probability of selection, this is
known as an 'equal probability of selection' (EPS) design. Such designs are also referred to
as 'self-weighting' because all sampled units are given the same weight.
Systematic Sampling,
Cluster Sampling
Example: We visit every household in a given street, and interview the first person to
answer the door. In any household with more than one occupant, this is a nonprobability
sample, because some people are more likely to answer the door (e.g. an unemployed
person who spends most of their time at home is more likely to answer than an employed
housemate who might be at work when the interviewer calls) and it's not practical to
calculate these probabilities.
Accidental Sampling,
Quota Sampling and
Purposive Sampling.
In addition, nonresponse effects may turn any probability design into a nonprobability
design if the characteristics of nonresponse are not well understood, since nonresponse
effectively modifies each element's probability of being sampled.
…..property of keiway mining and technology college………compiled by Mr. Mutuku………
127
Computational mathematics………mathematics is a life style……live it…
Applicable when population is small, homogeneous & readily available. All subsets of the
frame are given an equal probability. Each element of the frame thus has an equal
probability of selection. It provides for greatest number of possible samples. This is done
by assigning a number to each unit in the sampling frame. A table of random number or
lottery system is used to determine which units are to be selected.
Systematic sampling
Relies on arranging the target population according to some ordering scheme and then
selecting elements at regular intervals through that ordered list. Systematic sampling
involves a random start and then proceeds with the selection of every kth element from
then onwards. In this case, k=(population size/sample size). It is important that the starting
point is not automatically the first in the list, but is instead randomly chosen from within
the first to the kth element in the list. A simple example would be to select every 10th
name from the telephone directory (an 'every 10th' sample, also referred to as 'sampling
with a skip of 10').
ADVANTAGES:
DISADVANTAGES:
Stratified sampling
Where population embraces a number of distinct categories, the frame can be organized
into separate "strata." Each stratum is then sampled as an independent sub-population, out
of which individual elements can be randomly selected. Every unit in a stratum has same
chance of being selected. Using same sampling fraction for all strata ensures proportionate
representation in the sample. Adequate representation of minority subgroups of interest can
be ensured by stratification & varying sampling fraction between strata as required.
Finally, since each stratum is treated as an independent population, different sampling
approaches can be applied to different strata.
128
Computational mathematics………mathematics is a life style……live it…
First, sampling frame of entire population has to be prepared separately for each
stratum
Second, when examining multiple criteria, stratifying variables may be related to
some, but not to others, further complicating the design, and potentially reducing
the utility of the strata.
Finally, in some cases (such as designs with a large number of strata, or those with
a specified minimum sample size per group), stratified sampling can potentially
require a larger sample than would other methods
Cluster sampling
Advantages:
129
Computational mathematics………mathematics is a life style……live it…
A measure of central tendency is a measure that tells us where the middle of a bunch of
data lies.
Mean
Median
Mode
Quartiles
Percentiles
Deciles
Mean
The mean is the average of the numbers.
Example 1
6, 11, 7
The Mean is 8
Example 2:
3, 7, 5, 13, 20, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29
130
Computational mathematics………mathematics is a life style……live it…
Example 3:
3, −7, 5, 13, −2
Median Value
The Median is the middle number in a sorted list of numbers.
To get the middle number if the total number of values (n) given is odd
n/2
Example 1:
3, 13, 7, 5, 21, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29
3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 39, 40, 56
There are fifteen numbers. Our middle number will be the eighth number:
I.e. 15/2 = 8
3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 39, 40, 56
131
Computational mathematics………mathematics is a life style……live it…
Example 2
3, 13, 7, 5, 21, 23, 23, 40, 23, 14, 12, 56, 23, 29
3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 40, 56
There are now fourteen numbers and so we don't have just one middle number, we have a
pair of middle numbers:
3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 40, 56
To find the value half-way between them, add them together and divide by 2:
21 + 23 = 44
44 ÷ 2 = 22
Mode
The mode is the number which appears most often.
Example:
3, 7, 5, 13, 20, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29
3, 5, 7, 12, 13, 14, 20, 23, 23, 23, 23, 29, 39, 40, 56
132
Computational mathematics………mathematics is a life style……live it…
Example:
1, 3, 3, 3, 4, 4, 6, 6, 6, 9
Mean
∑ 𝑓𝑥
Mean ( x ) =
∑𝑓
Example
The marks of seven students in an economics test out of a total of 20 marks are
∑ 𝑓𝑥 303
Mean ( x ) = = = 15.15
∑𝑓 20
133
Computational mathematics………mathematics is a life style……live it…
Mode = 17
15+15
Median = = 15
2
Mean
Suppose you asked a group of men to count the number of items in their Pockets
Number Mid-point fx
Frequency
of items Of class (x)
0-4 6 2 12
5-9 11 7 77
10-14 6 12 72
15-19 4 17 68
20-24 3 22 66
∑ 𝑓 = 30 ∑ 𝑓𝑥 = 295
∑ 𝑓𝑥 295
Mean ( x ) = = = 9.8
∑𝑓 30
134
Computational mathematics………mathematics is a life style……live it…
Mode
𝑓𝑖 − 𝑓𝑖−1 𝑓𝑖 − 𝑓𝑖−1
Mode = li + ( (𝑓𝑖 ) × ai = li + ( 2𝑓𝑖 ) × ai
− 𝑓𝑖−1)(𝑓𝑖 − 𝑓𝑖+1) − 𝑓𝑖−1 − 𝑓𝑖+1
Example
Number Mid-point fx
Frequency
of items Of class (x)
0-4 6 2 12
5-9 11 7 77
10-14 6 12 72
15-19 4 17 68
20-24 3 22 66
∑ 𝑓 = 30 ∑ 𝑓𝑥 = 295
𝑓𝑖 − 𝑓𝑖−1
Mode = li + ( 2𝑓𝑖 ) × ai
− 𝑓𝑖−1 − 𝑓𝑖+1
11 − 6
= 4.5 + ( 2×11 )×5
− 6 − 6
5
= 4.5 + ( 22−12 ) × 5
5
= 4.5 + ( 10) × 5
135
Computational mathematics………mathematics is a life style……live it…
Median
𝑁
− 𝑓𝑖−1
2
Median = li + × ai
𝑓𝑖
Where
Example
Number
Frequency c.f
of items
0-4 6 6
5-9 11 17
10-14 6 23
15-19 4 27
20-24 3 30
∑ 𝑓 = 30
𝑁
− 𝑓𝑖−1
2
Median = li + × ai
𝑓𝑖
30
− 6
2
Median = 4.5 + ×5
11
15 − 6
= 4.5 + ×5
11
9
= 4.5 + × 5 = 8.59
11
136
Computational mathematics………mathematics is a life style……live it…
N-TILES
Quartiles
Quartiles divides a set of data which has been arranged in ascending order into 4 equal
parts.
The first quartile Q1 is a point in the distribution below which 25% of the data lie.
Second quartile Q2 is the median i.e. point in the distribution below which 50% of the data
lie.
Third quartile Q3 is a point in the distribution below which 75% of the data lie.
Deciles
Percentile
137
Computational mathematics………mathematics is a life style……live it…
Example
Class f x c.f
interval
25 – 29 5 27 5
30 – 34 12 32 17
35 – 39 25 37 32
40 – 44 11 42 43
45 – 49 7 47 50
1
× 50 −5
4
Q1 = 29.5+ ( )×5
12
7.5
= 29.5 + ×5
12
= 29.5 + 3.125
= 32.625
3
4
× 50−32
D4 = 39.5+ ( )×5
12
5.5
= 29.5 + ×5
11
= 29.5 + 2.5
= 32
138
Computational mathematics………mathematics is a life style……live it…
4
× 50−17
10
D4 = 34.5+ ( )×5
25
3
= 34.5 + 25 × 5
= 34.5 + 0.6
= 35.1
65
× 50−32
100
P65 = 39.5+ ( )×5
11
0.5
= 39.5 + 11 × 5
= 39.5 + 0.23
= 39.73
139
Computational mathematics………mathematics is a life style……live it…
Measure of variation gives us some idea on how the values of distribution cluster around
the average.
Includes
Range
Mean absolute deviation
Standard deviation
Range
Is difference between the largest and the smallest value. Is a quick measure of variability
but not accurate since it is badly affected by just one extreme value.
Inter-quartile Range
Is the difference between the upper quartile and the lower quartile.
IR = Q3 – Q1
Semi-interquartile range
𝑄3−𝑄1
Is given by 2
Also known as the mean deviation. It is a good measure of dispersion since all the values
are involved in its computation.
It is defined as
∑ |𝑥𝑖− 𝑥 | ∑ 𝑓|𝑥𝑖− 𝑥 |
or ∑ 𝑓𝑖
𝑛
Where fi is the frequency of xi and |xi - 𝑥 | is the absolute deviations from the mean
Example 1
140
Computational mathematics………mathematics is a life style……live it…
Solution
∑ |𝑥𝑖− 𝑥 |
MAD = 𝑛
57+55+62+52+54+45+57+66
But 𝑥 = = 56
8
x 𝑥𝑖 − 𝑥 |𝑥𝑖 − 𝑥 |
57 1 1
55 -1 1
62 6 6
52 -4 4
54 -2 2
45 -11 11
57 1 1
66 10 10
∑ |𝑥𝑖 − 𝑥 | = 36
36
MAD = = 4.5
8
They are the most useful measures of variation for further statistical analysis
∑(𝑥𝑖− 𝑥 )2
Standard deviation = √ 𝑛
141
Computational mathematics………mathematics is a life style……live it…
∑ 𝑓(𝑥𝑖− 𝑥 )2
Standard deviation = √ ∑ 𝑓𝑖
Example
Determine the mean absolute deviation, the variance and the standard deviation of the
following data
Class
f x fx 𝑥𝑖 − 𝑥 𝑓|𝑥𝑖 − 𝑥 | f(𝑥𝑖 − 𝑥 )2
interval
24 – 29 5 27 135 -10.25 51.25 525.3125
30 – 34 12 32 384 -5.25 63 47628
35 – 39 25 37 925 -0.25 6.25 976.5625
40 – 44 11 42 462 4.75 52.25 30030.6875
45 – 49 7 47 329 9.75 68.25 32606.4375
∑ 𝑓𝑥 = 2235 ∑ 𝑓|𝑥𝑖 − 𝑥 | ∑ 𝑓(𝑥𝑖 − 𝑥 )2
∑ 𝑓 = 60
= 241 = 111767
∑ 𝑓𝑥 2235
Mean ( 𝑥 ) = = = 37.25
∑𝑓 60
∑ 𝑓|𝑥𝑖− 𝑥 | 241
MAD = ∑𝑓
= = 4.02
60
∑ 𝑓(𝑥𝑖− 𝑥 )2 111767
Variance = ∑ 𝑓𝑖
= = 1862.78
60
142
Computational mathematics………mathematics is a life style……live it…
Skewness
1. Symmetric
Mean, median, and mode are all the same here; mound shaped, no skewness (symmetric).
143
Computational mathematics………mathematics is a life style……live it…
Kurtosis
Fig. 1
Fig. 2
144
Computational mathematics………mathematics is a life style……live it…
Fig. 3
-Normal distribution which is not high peaked neither flat-topped as in fig. 2 is called
mesokurtic.
145