0% found this document useful (0 votes)
40 views145 pages

Understanding Number Systems in Computing

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, explaining their bases and how they represent data. It also discusses the conversion methods between these number systems, along with examples, and touches on negative number representation and binary arithmetic. Overall, it highlights the importance of understanding these systems in computational mathematics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views145 pages

Understanding Number Systems in Computing

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, explaining their bases and how they represent data. It also discusses the conversion methods between these number systems, along with examples, and touches on negative number representation and binary arithmetic. Overall, it highlights the importance of understanding these systems in computational mathematics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computational mathematics………mathematics is a life style……live it…

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.

Examples of number system include:

 Decimal number system


 Binary number system
 Octal number system
 Hexadecimal number system

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.

Decimal number System


-The Decimal Number System consists of ten digits from 0 to 9.
-These digits can be used to represent any numeric value.
-The base of decimal number system is 10.
-It is the most widely used number system.
-The value represented by individual digit depends on weight and position of the digit.
-Each digit has a position value determined by how many places to the right or left of the
decimal point the digit is written
-Position value are in increasing powers of the base as we move left and decreasing power
of the base as we move to right.

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

The value of each digit in a number depends upon


 The face value of the digit
 The base of the system
 The position of the digit in the number

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

1
Computational mathematics………mathematics is a life style……live it…

Binary Number System


-Digital computer represents all kinds of data and information in the binary system.
-Binary Number System consists of two digits 0 and 1.
-Its base is 2.
-Each digit or bit in binary number system can be 0 or 1.
-A combination of binary numbers may be used to represent different quantities like 1001.
-The positional value of each digit in binary number is twice the place value or face value
of the digit of its right side.
-The weight of each position is a power of 2.
-Computer handles data by electrical components like transistors, semi-conductors,
integrated circuits or wires which exist in two states.
-A transistor may be conducting or not.
-Magnetic material may be magnetized in one direction or the other.
-A wire may or may not be carrying a current.
-Computer understands only one language consisting of two symbols, 0’s and 1’s, what we
call binary language.
-The most common way to represent data is by the use of numerals 0 to 9 and alphabets A
to Z along with other symbols like +, -, ×, etc.
-Computer is unable to understand the supplied data represented by the symbols.
-The data needs to be changed to computer language for the computer to understand it
-Also, data processed by the computer must be decoded in the form understandable by the
user.

Converted
CPU
to
Human Input works on
computer
message the data
language

Decoded
to human
language

Human
readable
data

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

2
Computational mathematics………mathematics is a life style……live it…

Octal Number System


-Octal Number System consists of eight digits from 0 to 7.
-The base of octal system is 8.
-Each digit position in this system represents a power of 8.
-Any digit in this system is always less than 8.
-Octal number system is used as a shorthand representation of long binary numbers.
-The number 6418 is not valid in this number system as 8 is not a valid digit.
-Base 8 is a convenient shorthand for base 2 numbers because 8 is a power of 2:2 3 = 8.
-One Octal digit is the equivalent of exactly three binary digits.
-The use of Octal (or Hexadecimal) as a shorthand for binary is common in printed output
of main storage and, in some cases in programming.
-Complex binary numbers with several 1’s and 0’s can be conveniently handled in base 8.
-The binary digits are grouped into binary digits of 3 from your right hand side and each
group is used to represent an individual octal digit.

E.g. the binary number 100011100112 can be handled as 21638

010 001 110 011


2 1 6 3

Hexadecimal number system


-The Hexadecimal Number System consists of 16 digits from 0 to 9 and A to F.
-The alphabets A to F represent decimal numbers from 10 to 15.
-So the base 16 numbers are: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E and F.
-The base of this number system is 16.
-Each digit position in hexadecimal system represents a power of 16.
-The number 76416 is valid hexadecimal number. It is different from 76410 which are seven
hundred and sixty four.
-This number system provides shortcut method to represent long binary numbers.
-Hexadecimal numbers are used to because more complex binary notations can be
simplified by grouping the binary digit/bits into groups of 4 from your right hand side each
group representing a hexadecimal digit.

E.g. the binary number 10010101000002 can be handled as 12A016.

1 0010 1010 0000


1 2 A 0

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

3
Computational mathematics………mathematics is a life style……live it…

Types of data
 Numeric data
 Alphabetic data
 Alphanumeric data

Conversion between number bases


Data passed to go as computer are usually in decimal notation
Also the output is communicated to the users in the form they can understand.

Conversion from decimal to binary


The number in base 10 is repeatedly divided by 2, until the dividend is zero.
In each division the remainder is noted and copied bottom up wise to give the binary
equivalent of the decimal number.

E.g. Convert 12110 to binary

Solution

1111001

Hence 12110 = 11110012

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

4
Computational mathematics………mathematics is a life style……live it…

Examples:

Convert the decimal number 163.75 and 202.9 into binary

10100011.11

11001010.11100

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

5
Computational mathematics………mathematics is a life style……live it…

Conversion from binary to decimal

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.

Example: convert the binary number 11110012 to decimal number

26 25 24 23 22 21 20

1 1 1 1 0 0 1

64 + 32 + 16 + 8 + 0 + 0 + 1

12110

For fraction numbers, the whole number is converted to decimal as above.

For the fraction part, digits are divided by multiples of two starting from the binary
point

Example 1: convert 11010.012 to decimal number

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

Example 2: convert 11100010.11012

27 26 25 24 23 22 21 20 . 2-1 2-2 2-3 2-4

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 + 0.5 + 0.25 + 0.0625

226.812510
…..property of keiway mining and technology college………compiled by Mr. Mutuku………

6
Computational mathematics………mathematics is a life style……live it…

Conversion from decimal to octal

You repeatedly divide the decimal number by 8.

E.g. convert decimal 69110 to octal

Solution

12638

For fraction numbers, the number is divided into two parts, the whole part and the
fraction part.

The whole part is then converted to binary individually as above.

The fraction part is repeatedly multiplied by 8 noting the complete units of 8

Example 1: convert 98.12510 to octal

Solutions

142.18

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

7
Computational mathematics………mathematics is a life style……live it…

Example 2: convert 202.9 to octal

Solutions

312.714638

Conversion from octal to decimal

Procedure is the same as binary to decimal, but the weights are assigned in terms of
8’s

Example: convert 12638 to decimal

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

8
Computational mathematics………mathematics is a life style……live it…

Example: convert 243.648 to decimal number

Solutions

82 81 80 . 8-1 8-2

2 4 3 . 6 4

6 4
128 + 32 + 3 + +
8 64

163 + 0.75 + 0.0625

163.812510

Conversion from decimal to hexadecimal


The procedure is the same as from decimal to binary, though divisions are by 16.

Example: convert 12210 to hexadecimal

Solutions

But A = 10

Hence, answer is 7A16

For fraction number, the fraction part is multiplied by 16 noting the complete units of 16’s.

Example: convert 32.12510 to hexadecimal

Solutions

20.216

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

9
Computational mathematics………mathematics is a life style……live it…

Conversion from hexadecimal to decimal

The same procedure as from binary to decimal is used with weights assigned in terms of
16’s.

Example: convert 7A16 to decimal number

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.

Example: convert 20.216 to decimal

Solutions

161 160 . 16-1

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

Various methods are used to represent negative numbers

 One’s complement (1C) method


 Two’s complement (2C) method
 Signed magnitude method

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

One’s complement (1C) method

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.

For example; -1710 can be represented in binary as

1710 = 100012

-1710 = 011102

Two’s complement (2C) method

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.

For example; -1710 can be represented as

1710 = 100012

-1710 = 01110
+ 1
01111

Signed magnitude method


In this method the number is divided into two parts, the sign and the data part.

Conventionally, a ‘1’ is used to represent a negative sign and a ‘0’ to represent a positive
sign.

The magnitude part is expressed in binary but not complemented.

The binary digits therefore will be having part of them representing the data while the
others the sign bit

The sign only takes one bit

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

13
Computational mathematics………mathematics is a life style……live it…

The subtraction can also be carried out using the complement and signed magnitude.

For example: using one’s complement

Make the number of bits of the values the same

Complement the digits of the negative number and then add

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

14
Computational mathematics………mathematics is a life style……live it…

Make the digits of the values the same

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

The overflow ignore

= 10 0 1 12

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

1110 rem 100

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Units of Computer Memory Measurements:


1 Bit = Binary Digit
8 Bits = 1 Byte
1 Nybble (or nibble) = 4 bits
1 Byte = 2 nybbles = 8 bits
1024 Bytes =1KB(KiloByte)
1024KB =1MB (MegaByte)
1024MB =1GB (GigaByte)
1024GB =1TB (TerraByte)
1024TB =1PB (PetaByte)
1024PB =1EB (ExaByte)
1024EB =1ZB (ZettaByte)
1024ZB =1YB (YottaByte)
1024YB =1 (BrontoByte)
1024Brontobyte =1(GeopByte)

Geop Byte is The Highest Memory Measurement Unit!!!

N/b: A byte is the smallest addressable unit of memory.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Advantages of Binary Code

Following is the list of advantages that binary code offers.

 Binary codes are suitable for the computer applications.


 Binary codes are suitable for the digital communications.
 Binary codes make the analysis and designing of digital circuits if we use the
binary codes.
 Since only 0 & 1 are being used, implementation becomes easy.

Need for binary codes


Suitable for computers because computer is a digital system that understand only binary
language i.e. language of 1’s and 0’s. Binary is the simplest way to implement operations
and information in a computer.

Classification of binary codes


The codes are broadly categorized into following four categories.

 Weighted Codes
 Non-Weighted Codes
 Sequential codes
 Alphanumeric Codes
 Reflective codes
 Error Detecting Codes
 Error Correcting Codes

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Weighted Non-weighted Reflective Sequential Alphanumeric Error


detecting

8421 Exces-3 Exces-3 8421 ASCII Parity


2421 5211 EBCDIC
5211 Gray 2421 Exces-3 UNICODE
codes codes codes codes codes

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

It is particularly significant for arithmetic operations as it overcomes the shortcomings


encountered while using the 8421 BCD code to add two decimal digits whose sum exceeds
9. This code is used in some old computers.

Example

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Conversion from binary to gray code


Steps:

 Place a leading zero before the most significant bit (MSB)


 Compare the adjacent bit starting from the leading zero
 If the two compared bits are the same => 0, if not =>1

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

21
Computational mathematics………mathematics is a life style……live it…

For example:

Conversion from gray code to binary


Steps:

 Drop the most significant bit (MSB)


 Compare this to the next adjacent bit
 If the two compared bits are the same => 0, if not =>1

For example

Application of Gray code

 Gray code is popularly used in the shaft position encoders.


 A shaft position encoder produces a code word which represents the angular
position of the shaft.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

22
Computational mathematics………mathematics is a life style……live it…

Representation of BCD numbers

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

Packs two decimal digits into a single byte.

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)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

24
Computational mathematics………mathematics is a life style……live it…

786 + 456 = 1242

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

25
Computational mathematics………mathematics is a life style……live it…

41 - 18 = 23

Using 9’s complement


The decimal equivalent of the given binary coded decimal codes are found out. Then the
9’s complement of the subtrahend is done and then the result is added to the number from
which the subtraction is to be done. If there is any carry bit, then the carry bit is added to
the result of the subtraction.

Example

0101 0001 – 0010 0001

51 – 21

9’s complement of 21 => 99 – 21 = 78

51 + 78 = 129

In this 1 is a carry. Therefore, 29 + 1 = 30, this is final answer.

The decimal result is then changed to BCD code to get the result

30 => 0011 0000

Using 10’s complement

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

0101 0001 – 0010 0001

51 – 21

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

26
Computational mathematics………mathematics is a life style……live it…

To get 10’s complement, we get the 9’s complement and add a 1.

So, 9’s complement of 21 => 99 – 21 = 78 + 1 = 79

51 + 79 = 130

Ignore the overflow. Hence the answer is 30

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

1001 × 0100 = 0011 0110

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

27
Computational mathematics………mathematics is a life style……live it…

Example

0010 1000 ÷ 0111 = 0100 (28 ÷ 7 = 4)

Exercise

0101 0010 ÷0100

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

ii. EBCDIC code


The EBCDIC stands for Extended Binary Coded Decimal Interchange Code.
IBM invented this code to extend the Binary Coded Decimal which existed at that time.
All the IBM computers and peripherals use this code.
It is an 8 bit code and therefore can accommodate 256 characters.
Divided into two parts, the first 4 bits are called the zone and represent the category of the
character, whereas the last 4 bits are called the digit and identify the specific character.

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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,....).

Use of Parity Bit

 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).

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

How error detection work

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

 Parity only detects an odd number of errors


 Parity cannot be used to detect which bit is in error.

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

There are 4 standard gates:

 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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Device enable or disable switch e.g. stop-watch.

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Also called inverter.

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

34
Computational mathematics………mathematics is a life style……live it…

Truth table

input Output
0 1
1 0

Application

Calculating 1’s complement.

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

36
Computational mathematics………mathematics is a life style……live it…

Application

Washing machine controller.

Other types of gates are

 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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

38
Computational mathematics………mathematics is a life style……live it…

Type of gate Notations


AND gate A.B

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

Draw the following circuit diagram

(A + B).(A + C)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Rule in Boolean algebra

Following are the important rules used in Boolean algebra.

 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

There are six types of Boolean Laws.

Commutative law

Any binary operation which satisfies the following expression is referred to as


commutative operation

Commutative law states that changing the sequence of the variables does not have any
effect on the output of a logic circuit.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Distributive law states the following condition.

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…

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Quadratic equations are equations of the form

ax2+ bx +c = 0

where a, b and c are constants and x is the variable and a = 0.

Methods of solving quadratic equations

 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;

 Get the product of a.c


 Get the sum b
 Find two numbers which when you multiply you get product a.c and when you add
them you get sum b

Example

Solve using factorization method 2x2 + 7x – 15 = 0

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

43
Computational mathematics………mathematics is a life style……live it…

Solution

product p = -30 and the sum b = 7

the two numbers are 10 and -3

hence 2x2 + 7x – 15 = 0 becomes 2x2 +10x - 3x – 15 = 0

= 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

Completing square method

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.

Let’s start with

x2 + bx

N/B: x2 should have a coefficient of one. That is required in order to do this.


𝑏
Now, to this lets add ( 2 )2. Doing this gives the following factorable quadratic equation.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

This method is used when it is not easy to factorize quadratic equations.

Example

Solve 5x2 – 6x – 2 = 0

Solutions

Divide through by 5 to get

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

45
Computational mathematics………mathematics is a life style……live it…

Exercise

Solve by complete square method

 2x2 – 6x -1 = 0
 x2 + 7x – 3 = 0
 -7 + 12x – 3x2 = 0

Quadratic formula

Complete square method can be generalized to the quadratic formula.

Consider the equation ax2 + bx + c =0


𝑏 𝑐
= x2 + 𝑎 x = - 𝑎

Complete the square


𝑏 𝑏 𝑐 𝑏
x2 + 𝑎 x + (2𝑎 )2 = - 𝑎 + (2𝑎 )2

𝑏 𝑐 𝑏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

Solve the equation using quadratic formula

3x2 – 7x – 1 = 0

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

46
Computational mathematics………mathematics is a life style……live it…

Solutions

− 𝑏 ± √𝑏2 −4𝑎𝑐
x = 2𝑎

a = 3, b = -7, c = -1

− (−7) ± √(−7)2 −(4×3×−1)


x =
2×3

7 ± √49+12
x = 6

7 ± √61
x = 6

7 + √61 7− √61
x = or x =
6 6

Exercise

Solve using quadratic formula

5x2 + 3x – 7 = 0

4 + 13y + y2

Graphical method

Steps

 Using a suitable scale to draw the x and y planes


𝜕𝑦
 Check the turning point by equating the =0
𝜕𝑥
 Locate the x-intercepts; the points where curve cuts the x-axis. Those are the
solutions of the quadratic equation.

Example

Using graphical method, solve

x2 – 3x + 2 = 0

in the interval -2 ≤ x ≤ 3

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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:

Using graphical method, solve

1. x2 – 6x + 6 = 0
2. 4x2 – 25x + 28 = 0

MATRIX

A matrix is a rectangular array of numbers, symbols or expressions arranged in rows and


columns.

Some definitions:

Row matrix (Row vector)

This is a matrix with only one row.


…..property of keiway mining and technology college………compiled by Mr. Mutuku………

48
Computational mathematics………mathematics is a life style……live it…

Column matrix (column vector)

This is a matrix with only one column.

Rectangular matrix

A matrix who’s the number of rows is not equal to the number of columns.

Square matrix

A matrix who’s the number of rows is equal to the number of columns.

Singular matrix

This is a matrix that does not have a matrix inverse.

In singular matrix the determinant is 0(zero).

2 1
E.g. ( ) => determinant = (2×1)-(2×1) = 0
2 1

Non- singular matrix

This is a matrix that has a matrix inverse. I.e. its determinant is not 0(zero).

Null matrix

Also called zero matrix.

Is a matrix with all its entries zero.

Identity matrix

Also called unit 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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

49
Computational mathematics………mathematics is a life style……live it…

Matrix operations

Addition

Is done entry wise.

𝑎 𝑏 𝑤 𝑥 𝑎+𝑤 𝑏+𝑥
+ 𝑦 𝑧 =
𝑐 𝑑 𝑐+𝑦 𝑑+𝑧

Example:

−2 6 3 7 1 13
3 −5 + −4 3 = −1 −2
4 −8 0 2 4 −6

Subtraction

Is also done entry wise.

𝑎 𝑏 𝑤 𝑥 𝑎−𝑤 𝑏−𝑥
- 𝑦 𝑧 =
𝑐 𝑑 𝑐−𝑦 𝑑−𝑧

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:

There are two types of multiplication for matrices:

 scalar multiplication
 matrix multiplication.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

When we do 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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

51
Computational mathematics………mathematics is a life style……live it…

(1.0) + (0. −2) + (−2.0) (1.3) + (0. −1) + (−2.4)


[ ]
(0.0) + (3. −2) + (−1.0) (0.3) + (3. −1) + (−1.4)

0+0+0 3+0−8
= [ ]
0−6+0 0−3−4

0 −5]
= [
−6 −7

Calculating the determinant of a matrix

 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| |
ℎ 𝑖 𝑔 𝑖 𝑔 ℎ

= a(ei - fh) + b (di - fg) + c (dh - eg)

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

= 3(0--2) + 0(2-0) + 2(2-0)

= 6 + 0 + 4 = 10

10

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

52
Computational mathematics………mathematics is a life style……live it…

Determining the inverse of a matrix

 2 by 2 matrix

Steps:

 Find the determinant


 Interchange the positions of the elements in the major diagonal and change the sign
of elements in the minor diagonal.
1
 Finally take 𝑑𝑒𝑡 times the matrix obtained above.

3 2
Example: find the inverse of the matrix A = [ ]
−1 −2

Det A = (3.-2) - (-1.2) = -6 – -2 = -6 + 2 = -4

1 1
1 −2 −2 1 −2 −2
= 𝑑𝑒𝑡 [ ]=- [ ] = [ 2 1 2 3]
1 3 4 1 3 −4 −4

 3 by 3 matrix

Two methods of calculating inverse of 3 by 3 matrix

 Co-factor method
 Row reduction method

Co-factor method

Steps:

 Calculate the determinant


 Calculate the matrix of minors
 Turn that matrix of minors to matrix of co-factor
 Then adjugate (Transpose)
1
 Multiply the adjugate by 𝑑𝑒𝑡

Example: calculate the inverse matrix of

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

53
Computational mathematics………mathematics is a life style……live it…

3 0 2
A= 2 0 −2
0 1 1

Step 1: calculating the determinant

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

= 3(0--2) + 0(2-0) + 2(2-0)

= 6 + 0 + 4 = 10

10

Step 2: calculating the matrix of minors

For each element of the matrix,

a. Ignore the value on the current row and column


b. Calculate the determinant of the remaining values

Put those determinants into matrix (the matrix of minors)

3 0 2
2 0 −2
0 1 1

0 −2
= | |
1 1

2 −2
= | |
0 1

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Step 3: Change the matrix of minors to matrix of co-factors

We need to change the sign of alternate cells, like this:

2 2 2 + − + 2 −2 2
−2 3 3 − + − = 2 3 −3
0 −10 0 + − + 0 10 0

Matrix of minors matrix of co-factors

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Row reduction method(Gauss-Jordan Elimination)

An n×n square matrix A is called invertible if there exist matrix X such that;

AX = XA = I (identity)

Where I is the n×n identity matrix

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

57
Computational mathematics………mathematics is a life style……live it…

There are 3 kinds of row operations

 Swapping

1 2 3 1 2 3
Eg. 4 5 6 R2 R3 7 8 9
7 8 9 4 5 6

 Multiplying or dividing a row by a non-zero number

1 2 3 1 2 3
Eg. 4 5 6 R2π 4𝜋 5𝜋 6𝜋
7 8 9 7 8 9

 Adding a multiple of a row to another row

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.

A matrix is in reduced echelon form if it satisfies the following conditions;

 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.

N/B: All the identity matrices are in reduced echelon form.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

58
Computational mathematics………mathematics is a life style……live it…

Examples:

State whether the following matrices are in reduced echelon form

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

Using row reduction, find the inverse matrix

1 1 −1
1. 2 −1 1
1 1 2

1 −1 2
2. −3 3 −1
2 −1 0

Using matrices to solve simultaneous equations

There are 3 methods

 Cramer’s rule
 Inverse method
 Row reduction method (Gaussian elimination)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

59
Computational mathematics………mathematics is a life style……live it…

Cramer’s Rule

Is a method for solving linear simultaneous equations. It makes use of determinants

Two equations

a1x + b1y = d1

a2x + b2y = d2

Then x, y can be formed from

𝐷𝑥 𝐷𝑦
x= and y =
𝐷 𝐷

Example

Solve the equation

3x + 4y = -14

-2x – 3y = 11

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

61
Computational mathematics………mathematics is a life style……live it…

Then x, y and z can be found from

Therefore

𝐷𝑥 𝐷𝑦 𝐷𝑧
x= , y= , z=
𝐷 𝐷 𝐷

Example

Solve

2x + y + z = 3

x–y–z=0

x + 2y + z = 0

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

63
Computational mathematics………mathematics is a life style……live it…

2. Find the values of x, y and z


x + 2y = 0
-x + y + z = 1
x + 2y + 3z = 0
2 1
(ans: x = − 3 , y = , z = 0)
3

3. Find the values of x and y


7x + 3y = 15
-2x + 5y = -16
(ans: x = 3, y = -2)

4. Find the value of y


x + 2y + 3z = 17
3x + 2y + z = 11
x – 5y + z = -5
(ans: y = 2)

Inverse method

Using inverse method,

First write the simultaneous equations in matrix form

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

64
Computational mathematics………mathematics is a life style……live it…

A is called the matrix of coefficient.

So to solve, given AX = B, we multiply both sides by inverse of A.

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

65
Computational mathematics………mathematics is a life style……live it…

Exercise

Using inverse method, solve

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.

Gaussian Elimination (Row reduction method)

A method of solving a linear system of equations. This is done by transforming the


system's augmented matrix into row-echelon form by means of row operations. Then the
system is solved by back-substitution.

Example 1:

Use Gaussian elimination to solve the system of linear equations

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

66
Computational mathematics………mathematics is a life style……live it…

Add twice Row 1 to Row 2.

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:

Use Gaussian elimination to solve the system of linear equations

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

Simultaneously, in order to make it clear that row operations on equations correspond


exactly to row operations on matrices.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Add Row 1 to Row 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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

68
Computational mathematics………mathematics is a life style……live it…

Add twice Row 2 to Row 3.

x – 2y – 3z = 0

−y−z=3

− z = −2

1 −2 −3 0
=( 0 −1 −1 3)
0 0 −1 −2

Add −1 times Row 3 to Row 2.

Add −3 times Row 3 to Row 1.

x – 2y = 6

−y =5

− z = −2

1 −2 0 6
(
= 0 −1 0 5)
0 0 −1 −2

Add −2 times Row 2 to Row 1.

x = −4

−y=5

− z = −2

1 0 0 −4
=( 0 −1 0 5)
0 0 −1 −2

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

69
Computational mathematics………mathematics is a life style……live it…

Multiply Rows 2 and 3 by −1.

x = −4

y = −5

z=2

1 0 0 −4
=( 0 1 0 −5)
0 0 1 2

Example 3:

Use Gaussian elimination to solve the system of linear equations

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

70
Computational mathematics………mathematics is a life style……live it…

Add −2 times Row 1 to Row 2.

Add −1 times Row 1 to Row 3.

Swap Row2 and Row 3.

Add 4 times Row 2 to Row 3.

x – 2y6 – 6z = 12
− 2y− 6z = 10
0 = −1

Since the final equation


0=−1

Hence cannot be satisfied, and so this system has no solutions.

Using matrices to solve real life problems

Some of the industrial demand problems includes

 Out-put vector of the economy


 Message coding
 Storage of information

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

71
Computational mathematics………mathematics is a life style……live it…

Out-put vector of the economy

Leontief model

This topic introduces an important application of matrix inversion in modern economic


theory. The Leontief model describes a simplified view of an economy. Its goal is to
predict the proper level of production for each of several types of goods or service. The
proper level of production is the one which meets two requirements:

 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:

Industry Raw Materials Services Manufacturing


Raw Materials 0.02 0.04 0.04
Services 0.05 0.03 0.01
Manufacturing 0.2 0.01 0.1

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:

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

the new production levels.

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.

Message coding (cryptography)

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Matrices were used to do this.

Encryption process

1. Convert the text of the message into a stream of numeral values.


2. Place the data into a matrix
3. Multiply the data by the encoding matrix
4. Convert the matrix into a stream of numeral values that contains the encrypted
message

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”

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

(Ans: 1, -52, -7, -66, ……………-1, -2, 1)

Storage of information

In mathematics definition, a matrix finds application in computing and database


management, a basic starting point being the concept of arrays.

A two dimension arrays can function exactly like a matrix.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Cardinality of a set is the total number of elements in that set. Denoted by A

e.g. A {5,3,6,1,8,9} . Then A = 6

Types of sets

1) subset

If every element in a set A is also a member of set B then A is a subset of B,


i.e., A ⊂ B.

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

B is a proper subset of A if B is a subset of A, but B does not

equal A.

4) Empty set

The empty set, or null set, is a set which contains no elements,

and is denoted by the symbol ∅.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

78
Computational mathematics………mathematics is a life style……live it…

5) Complementary set

Suppose that A ⊂ S. The complement of set A, denoted as A/ is the set


containing all elements in S that are not in A

6) Universal set

The set of all possible outcomes of a random experiment is called the


sample space (or universal set) and is denoted by U.

7) disjoint of mutually exclusive


Two sets, A and B, are called disjoint of mutually exclusive sets if they
contain no common element. i.e., if A ∩ B = ∅.

Venn diagram

Graphical representation of a set with enclosed areas in the plane.

Basic operations of a set

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}.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

79
Computational mathematics………mathematics is a life style……live it…

Example

Let A = {1, 3, 5, 6, 7}, B = {3, 4, 5, 8} then

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

Let A = {1, 3, 5, 6, 7} and B = {3, 4, 5, 8}, then

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

80
Computational mathematics………mathematics is a life style……live it…

Example

Let A = {1, 2, 3, 4, 5} and B = {3, 4, 5, 6, 7}

Then A\B = {1, 2} and B\A = {6, 7}

Some Theorems involving sets:

 A ∪ B = B ∪ A (commutative law for unions)


 (A ∪ B) ∪ C = A ∪ (B ∪ C) (associative law for unions)
 A ∩ B = B ∩ A (commutative law for intersections)
 (A ∩ B) ∩ C = A ∩ (B ∩ C) (associative law for intersections)
 A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) (First distributive law)
 A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) (Second distributive law)
 If A ⊂ B then A/ ⊃ B/
 A ∪ ∅ = A and A ∩ ∅ = ∅
 (A ∪ B)/ = A/ ∩ B/ (De Morgan’s first law)
 (A ∩ B)/ = A/ ∪ B/ (De Morgan’s second law)

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

A/ ∩ (B∪C) = C∩ (B∪C) = {b, d, e, f} = C

Exercise

1. In a wedding ceremony attended by 400, drinks were taken as follows


i. 38 people drank coffee, 48 people drank tea and 39 people drank mineral
water.
ii. 15 people drank coffee and tea, 13 coffee and mineral water and 9 tea and
mineral water.
iii. 5 drank all the three drinks

Using venn diagram, determine how many of the people drank,

i. Mineral water only


ii. Tea and coffee but not mineral water
iii. Non of the 3 drinks

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

82
Computational mathematics………mathematics is a life style……live it…

i. Mineral water only = 12


ii. Tea and coffee but not mineral water = 5 + 15 + 19 = 39
iii. Non of the 3 drinks = 322

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.

The information given in the question can now be rewritten as

| M | = 31, | B | = 26, | M ∩ B | = 12 and | E | = 100.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

83
Computational mathematics………mathematics is a life style……live it…

Hence number in M only = 31 – 12 = 19

Number in B only = 26 – 12 = 14.

i. Number visiting Melbourne or Brisbane = 19 + 14 +12 = 45.


ii. Number visiting Brisbane only = 14.
iii. Number visiting only one city = 19 + 14 = 33.
iv. Number visiting neither city = 100 – 45 = 55.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

84
Computational mathematics………mathematics is a life style……live it…

Counting is also known as enumeration.

The two basic principles of counting

 The rule of sum


 The rule of product

Rule of sum

Also called the addition rule.

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

Total is 18 + 325 = 343

Example 2:

How many strings of 4 decimal digits have exactly three digits that are 9s?

Solution

The string can have

 The non-9 as the first digit


 Or the non-9 as the second digit
 Or the non-9 as the third digit
 Or the non-9 as the fourth digit

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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)

Thus, the answer is 9 + 9 + 9 + 9 = 36

Union Rule: |A∪B| = |A| + |B| - |A∩B|

Example

S = {a,b,c}

How many 3-letter words in S start with a or end in b?

Solution

Let A = 3 letter words starting with "a"

Let B = 3 letter words ending with "b"

Find: |A∪B|

Answer:

|A| = (1) (3) (3) = 1×3×3 = 9

|B| = (3) (3) (1) = 3×3×1 = 9

|A∩B| = (1) (3) (1) = 1×3×1 = 3

|A∪B| = 9 + 9 - 3 = 15

The product rule

Also called the multiplication rule.

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?

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

86
Computational mathematics………mathematics is a life style……live it…

Solution

Total is 18 × 325 = 5850

Example 2

How many strings of 4 decimal digits

a. Do not contain the same digit twice?


b. End with an even digit

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

b. First 3 digits have 10 possibilities


Last digit has 5 possibilities

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

First place the bride. She can be in one of the 6 positions

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Product rule yields 6 × 15120 = 90720

Product Rule: |A×B×C| = |A| × |B| × |C|

Example 1:

A = {1,2,3}, B = {a,b}, C = {a,b,g,d}

How many 3-character words with 1st character from A, 2nd from B, 3rd from C?

Answer: |A| × |B| × |C| = 3 × 2 × 4 = 24

Example 2:

3 Independents, 2 Democrats, 4 Republicans

How many ways to form 3-person committee with one member from each party?

Method: Count number of triples <Independent, Democrat, Republican>

Answer: 3 × 2 × 4 = 24

Inclusion- exclusion principle

When counting the possibilities, we cannot include a given outcome more than once.

|A| + |B| = |A| + |B| - |A∩B|

Let’s A have 5 elements, B have 3 elements and 1 element be both in A and B

Total in the union is 5 + 3 -1 = 7, not 8.

Inclusion/Exclusion Principle

To calculate |A1∪A2∪…∪An|,

1. Calculate size of all possible intersections

2. Add results from ∩ of odd numbered sets.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

88
Computational mathematics………mathematics is a life style……live it…

3. Subtract results from ∩ of even numbered sets.

I.e. |A1∪A2∪A3| = |A1| + |A2| + |A3| - |A1∩A2| - |A1∩A3| - |A2∩A3| + |A1∩A2∩A3|

Example:

How many integers in {1,…,1000} are divisible by either 2, 3, or 5?

A = divisible by 2

B = divisible by 3

C = divisible by 5

Find: |A∪B∪C|

|A| = |{2,4,…,1000}| = 500

|B| = |{3,6,…,999}| = 333

|C| = |{5,10,…,1000}| = 200

|A∩B| = |{6,12,18,…,996}| = 166

|A∩C| = |{10,20,…,1000}| = 100

|B∩C| = |{15,30,…,990}| = 66

|A∩B∩C| = |{30,60,…,990}| = 33

So, |A∪B∪C| = 500 + 333 + 200 - 166 - 100 - 66 + 33 = 734

Selection with Replacement


Permutations (Order Matters), with replacement: n r

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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?

Method: Choose 10 times from a set of 6.

Answer: 610

Example 2:

S = {0,1,…,7}

How many strings of length 5 are there in S?

Method: Choose 5 times from a set of 8.

Answer: 85

Combinations (Order Does Not Matter), with replacement: C(n+r-1,r)

Choose r times from a set of n items with replacement and order does not matter.

The number of possible outcomes is written as C(n+r-1,r).

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

Selection without Replacement


Permutations (Order Matters): P(n,r)

Choose r times from a set of n items without replacement and order matters. If we do not
have replacement but order matters:

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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)
𝑛!
=
(𝑛−𝑟)!

This is usually called permutations of n things taken r at a time. The number of


𝑛!
possible outcomes is P(n,r) = =
(𝑛−𝑟)!

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?

Method: Choose 20 from 57 without replacement, order matters


57!
Answer: P(57,20) =
37!

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?)

Method: Choose all n items from n, without replacement, order matters


𝑛! 𝑛!
Answer: P(n,n) = = = n!
(𝑛−𝑛)! 0!

Example 3:

S = {a,b,c,d,e,f}

How many 3-letter words are in S which have no character repeated?

Method: Choose 3 from 6 without replacement and order matters.


6!
Answer: P(6,3) = = 6 × 5 × 4 = 120
3!

Combinations (Order Does Not Matter) without replacement: C(n,r)

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

𝑝(𝑛,𝑟)! 𝑛!
=
𝑝(𝑟,𝑟)! (𝑛−𝑟)!𝑟!

This is usually referred to as combinations of n things taken r at a time = C(n,r).

There is another important type of combination, combinations with replacement. The


sequence can repeat, but order does not matter. (Discussed Earlier)
𝑛!
Number of ways to choose r from n is C(n,r) =
(𝑛−𝑟)!𝑟!

Example

How many ways can you choose a committee of 5 from 7 people?


7! 7×6
Answer: C(n,r) = = = 21
2!5! 2

Summary of Permutations and Combinations


Type (n things, r times) Order Replacement Symbol Expression
Counts
Permutations w/ repl. Yes Yes None nr
Permutations - no repl. Yes No P(n,r) 𝑛!
(𝑛−𝑟)!
Combinations - no repl. No No C(n,r) 𝑛!
(𝑛−𝑟)!𝑟!
Combinations - w/ repl. No Yes C(n+r-1,r) (𝑛+𝑟−1)!
𝑟!(𝑛−1)!

NB: n! = n × (n-1) × (n-2) × (n-3) ×………….× 4 × 3 ×2 × 1

0! = 1

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

How many 3 digit number can be made from the integers 2, 3, 4, 5, 6 if

a. If integer is used only once


b. There are no restriction on the number of times each integer can be used

Solution:

a. number of objects are 5

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

93
Computational mathematics………mathematics is a life style……live it…

a. Each digit may be used once


b. Each digit may be used more than once

Solution:

a. Consider the two digit numbers = 3 × 2 = 6


Then consider the 3 digit number = 2 × 2 × 1 = 4

Total = 6 + 4 = 10

b. Consider the two digit numbers = 3 × 3 = 9


Then consider the 3 digit number = 2 × 3 × 3 = 18
Total = 9 + 18 = 27

Example 2

How many ways can 4 students be chosen from 8 students

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?

Solution: for women = 9C6 and for men = 7C6

Total number of ways = 9C6 × 7C6 = 1764 ways

Permutations when some objects are alike

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

Determine the number of permutations of letters of the word “MISSISSIPPI”

Solution: n = 11, I’s = 4, S’s = 4, P’s =2

11!
= = 34650
4! × 4! × 2!

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

94
Computational mathematics………mathematics is a life style……live it…

The Binomial Theorem

A binomial is an algebraic expression containing 2 terms. For example, (x + y) is a


binomial. We sometimes need to expand binomials as follows:

(a + b)0 = 1

(a + b)1 = a + b

(a + b)2 = a2 + 2ab + b2

(a + b)3 = a3 + 3a2b + 3ab2 + b3

(a + b)4 = a4 + 4a3b + 6a2b2 + 4ab3 + b4

(a + b)5 = a5 + 5a4b + 10a3b2 + 10a2b3 + 5ab4 + b5

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.

The Binomial Theorem

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

95
Computational mathematics………mathematics is a life style……live it…

Properties of the Binomial Expansion (a + b)n


a. There are n+1 terms.
b. The first term is an and the final term is bn.
c. Progressing from the first term to the last, the exponent of a decreases by 1 from
term to term while the exponent of b increases by 1. In addition, the sum of the
exponents of a and b in each term is n.
d. If the coefficient of each term is multiplied by the exponent of a in that term, and
the product is divided by the number of that term, we obtain the coefficient of the
next term.

General formula for (a + b)n

First, we need the following definition:

Definition: n! Represents the product of the first n positive integers i.e.

n! = n(n − 1)(n − 2) ... (3)(2)(1)

We say n! as "n factorial".

Example 1

-factorial values

Here are some 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

Note: 2!4! cannot be cancelled down to 2!.

The formal expression of the Binomial Theorem is as follows:

(a + b)n = ∑ nCk an-k bk

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

96
Computational mathematics………mathematics is a life style……live it…

Example 1

Expand (x + 2)5

Solution

= 5C0(x)5(2)0 + 5C1(x)4(2)1 + 5C2(x)3(2)2 + 5C3(x)2(2)3 + 5C4(x)1(2)4 + 5C5(x)0(2)5

= x5 + 5.x4.2 + 10.x3.4 + 10.x2.8 + 5.x.16 + 32

= x5 + 10x4 + 40x3 + 80x2 + 80x + 32

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

Write the first 3 terms of the expansion


𝑥
1. (1 - 2)10 hence solve (0.05)10

2. (3 – 2x)8 hence solve (2.04)8

1
3. (1 + 2x)12 hence solve (1.0511)12 correct to 4 d.p

Binomial theorem for any index

In general,
𝑛(𝑛−1)
(a + b)n = an + nan-1 b + 2!
an-2b2 + 𝑛(𝑛−1)(𝑛−2)
3!
an-3b3 + 𝑛(𝑛−1)(𝑛−2)(𝑛−3)
4!
an-4b4 ……

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

97
Computational mathematics………mathematics is a life style……live it…

If first term is not 1, then make it to be 1 as follows;

𝑥 𝑥 𝑥
(a + x)n = [a(1 + )]n = an(1 + )n if | |<1
𝑎 𝑎 𝑎

Exercise
1.
Expand (1 + x)1/2
2.
Expand (1 – 2x)-3

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

98
Computational mathematics………mathematics is a life style……live it…

Plotting linear graph

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

Plot the graph of y = 3x + 2.

Solution:

Construct a table and choose simple x values.

In order to find the y values for the table, substitute each x value into the rule y = 3x + 2

When x = -2, y = 3(-2) + 2 = -4

When x = -1, y = 3(-1) + 2 = -1

When x = 0, y = 3(0) + 2 = 2

When x = 1, y = 3(1) + 2 = 5

When x = 2, y = 3(2) + 2 = 8

The table of values obtained after entering the values of y is as follows:

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Plot the graph of y = –2x + 4.

Solution:

When x = -2, y = -2(-2) + 4 = 8

When x = -1, y = -2(-1) + 4 = 6

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Y-intercept- the point where the line cuts the y-axis

X –intercept- the point where the line cuts the x-axis

Gradient- general equation of a line is y = mx + c

Where the m is the gradient and the c is the y-intercept

E.g. y = 3x + 5, the gradient is 3 and the y-intercept is 5

Exercise

Given the linear equation 2y = -3x – 7

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Presentation of data in charts

Data can be presented using the following charts

 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.

Favorite type of movie


Comedy Action Romance Drama SciFi
4 5 6 1 4

Now you need to figure out how many degrees for each "pie slice" (correctly called a
sector).

A Full Circle has 360 degrees, so we do this calculation:

Comedy Action Romance Drama SciFi TOTAL


4 5 6 1 4 20
4/20 = 20% 5/20 = 25% 6/20 = 30% 1/20 = 5% 4/20 = 20% 100%
4/20 × 360° 5/20 × 360° 6/20 × 360° 1/20 × 360° 4/20 × 360° 360°
= 72° = 90° = 108° = 18° = 72°

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Favorite type of movie


Comedy Action Romance Drama SciFi
4 5 6 1 4

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

103
Computational mathematics………mathematics is a life style……live it…

0
Comedy Action Romance Drama SciFi

Histograms vs Bar Graphs

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

A Pictograph is a way of showing data using images.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

The sample space denoted as S is S = (H, T)

For a single toss of a die, the sample space is S = (1, 2, 3, 4, 5, 6)

Event

Is a collection of elements satisfying a common requirement in a sample space. In case of a


die, the event of getting a face less than 5 is A= (1, 2, 3, 4)

Events are subsets of the sample space.

The probability of an event A is denoted as P(A)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Sample space S = [HH, HT, TH, TT]

Let A be the event of getting at least one head.

A = [HH, HT, TH]

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

Let H be the event of getting a head.

Let T be the event of getting a tail.

P(H) = 0.4 but sum of probability is 1

P(T) = 1 – 0.4 = 0.6

Exercise

Two dies A and B are rolled together

i. What are the elements of the sample space


ii. What is the probability that the sum of the face value of the two dies is 8
iii. What is the probability that at least one 5 appears in the list

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

By rolling a die twice, the results are independent events.

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.

Mutually Exclusive Events or Disjoint

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.

For example, if a die is thrown, an elementary event would be a 4.

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

For example, rolling a die and obtaining a face less than 7.

Impossible Event

The impossible event is an event that cannot occur, i.e. does not have an element. It has a
probability of 0.

For example, rolling a die and obtaining a score of 7.

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

i. Experimental probability/ classical probability


ii. Theoretical probability/ Axiomatic probability

Rules of probability

1. The probability of an event is between 0 and 1. A probability of 1 is equivalent to


100% certainty. Probabilities can be expressed at fractions, decimals, or percents.

0 ≤ P(A) ≤ 1

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

109
Computational mathematics………mathematics is a life style……live it…

2. The sum of the probabilities of all possible outcomes is 1 or 100%. If A, B, and C


are the only possible outcomes, then P(A) + P(B) + P(C) = 1

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.

P (A and B) = P(A) × P(B)

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

8. If event B is a subset of event A, then the probability of B is less than or equal to


the probability of A. P(B) ≤ P(A)

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.

P(A ∩ B) = P(A) P(B|A)

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Therefore, based on the rule of multiplication:

P(A ∩ B) = P(A) P(B|A)


P(A ∩ B) = (4/10) * (3/9) = 12/90 = 2/15

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.

P(A ∪ B) = P(A) + P(B) - P(A ∩ B))

Note: Invoking the fact that P(A ∩ B) = P( A ) × P( B | A ), the Addition Rule can also be
expressed as

P(A ∪ B) = P(A) + P(B) - P(A)P( B | A )

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:

P(F ∪ N) = P(F) + P(N) - P(F ∩ N)


P(F ∪ N) = 0.40 + 0.30 - 0.20 = 0.50

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Similarly, the conditional probability of B given that A is defined as

𝑃(𝐵∩𝐴)
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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Let A be the event of being in party A

Let B be the event of being in party B

Let L be the event of lying

Let T be the event of telling the truth

P(A) = 0.25, P(B) = 0.75

P(L/A) = 0.2, P(L/B) = 0.3

But

𝑃(𝐿∩𝐴)
P(L/A) = = > 𝑃(𝐿 ∩ 𝐴) = P(L/A) × 𝑃(𝐴)
𝑃(𝐴)

0.2 × 0.25 = 0.05

𝑃(𝐿∩𝐵)
P(L/B) = => 𝑃(𝐿 ∩ 𝐵) = P(L/B) × 𝑃(𝐵)
𝑃(𝐵)

0.3 × 0.75 = 0.225

i. Probability that he/she lies


i. P(L) = P(L/A) + P(L/B)
ii. 0.05 + 0.225 = 0.275
ii. Given that `lies, find the probability that he comes from A
𝑃(𝐿∩𝐴) 𝑃(𝐿/𝐴) × 𝑃(𝐴)
P(A/L) = =
𝑃(𝐴) 𝑃(𝐿)

0.2 × 0.25
𝑜.275

0.1818

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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)

𝑃(𝐴∩𝐵) 𝑃(𝐴) × 𝑃(𝐵)


I.e. (A/B) = = P(A)
𝑃(𝐵) 𝑃(𝐵)

BAYE’S THEOREM

The theorem states as follows:

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

A rental car delivered to the firm will need a tune-up

A car comes from agency 2 given that it needs tune-up

Solution

Let A be the event that a car needs tune-up

Let B1 be the event that a car needs tune-up from agency 1

Let B2 be the event that a car needs tune-up from agency 2

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

115
Computational mathematics………mathematics is a life style……live it…

Let B3 be the event that a car needs tune-up from agency 3

P(B1) = 0.6, P(B2) = 0.3, P(B3) = 0.1

P(A/B1) = 0.09, P(A/B2) = 0.2, P(A/B3) = 0.06

𝑃(𝐴∩𝐵𝑖)
P(A/Bi) = But 𝑃(𝐴 ∩ 𝐵𝑖) = P(A/Bi) × P(Bi)
𝑃(𝐵𝑖)

i. We need

P(A) = P(A/B1) × P(B1) + P(A/B2) × P(B2) + P(A/B3) × P(B3)

= (0.09 × 0.6) + (0.2 × 0.3) + (0.06 × 0.1)

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

A tree diagram consists of a number of branches defining the number of possible


outcomes at each stage.

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Let P be the event that a person tests positive

Let N be the event that a person tests negative

Let A be the event that a person has Aids

Let B be the event that a person has no Aids

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

117
Computational mathematics………mathematics is a life style……live it…

We use the following tree diagram

Test positive

P(AP) or P(BP)

(0.95 × 0.3) + (0.7 × 0.01)

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

118
Computational mathematics………mathematics is a life style……live it…

Use of binomial formula

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

ii. The experiment is repeated several independent trial


iii. The interest is the number of successes

Thus the probability of observing exactly x successes in n trials is given by

P(x) = nCx Px (1 – P)n-x , x= 1, 2, 3, ……….n

𝑛!
=> nCx = and this is binomial formula
𝑥!(𝑛−𝑥)!

Example

A fair coin is tossed 8 times. Find the probability of obtaining

i. Exactly 4 heads
ii. At least 6 heads
iii. At least 1 head

Solution

let H be the event of getting a head

let T be the event of getting a tail


1 1
P(H) = , P(T) = 2 , n = 8
2

P(x) = nCx Px (1 – P)n-x , x= 1, 2, 3, ……….n

1 1 8 1 35
i. P(4H) = 8C4(2)4 (2)4 = ( )8 =
4!(8−4)! 2 128

35
128

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

119
Computational mathematics………mathematics is a life style……live it…

ii. P(at least 6 heads) = P(6H) or P(7H) or P(8H)


1 1 1 7 1 1 1 8 1 0
= 8C6(2)6 (2)2 + 8C7( ) (2) + 8C8( ) (2)
2 2

37
=
256

iii. P(at least one head) = 1 – P(zero head)


1 1
= 1- 8C0(2)0 (2)8

255
=
256

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Categorized into two

 Primary source
 Secondary source

Primary data is the data collected by the researcher themselves, i.e.

1. interview
2. observation
3. action research
4. case studies
5. life histories
6. questionnaires
7. ethnographic research
8. longitudinal studies

Secondary sources are data that already exists. May include

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

121
Computational mathematics………mathematics is a life style……live it…

Primary Data Sources Secondary Data Sources


Data that are not pre-existing and are Information that has already been
collected by the evaluator using methods collected, processed and reported out by
such as observations, surveys or interviews another researcher/entity
Provides information if existing data on your Offers an opportunity to review any and
topic/project is not current or directly all secondary data available for your
applicable to your evaluation questions what project before collecting primary data
you need
Can be more expensive and time- Will tell you what questions still need to
consuming, but it enables you to collect data be addressed and what data you should
that is specific to the purpose of your collect yourself
evaluation

1. Observations

Observation is way of gathering data by watching behavior, events, or noting


physical characteristics in their natural setting.

Advantages

1. It makes it possible to collect different types of data.


2. It reduces the incidence of "reactivity" or people acting in a certain way when they
are aware of being observed.
3. It helps the researcher to develop questions that make sense in the native language
or are culturally relevant.
4. It gives the researcher a better understanding of what is happening in the culture
and lends credence to one's interpretations of the observation.
5. It is sometimes the only way to collect the right data for one's study

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Key design principles:

1. Keep the questionnaire as short as possible.


2. Ask short, simple, and clearly worded questions.
3. Start with demographic questions to help respondents get started comfortably.
4. Use dichotomous (yes | no) and multiple choice ques-tions.
5. Use open-ended questions cautiously.
6. Avoid using leading-questions.
7. Pretest a questionnaire on a small number of people.
8. Think about the way you intend to use the collected data when preparing the
questionnaire.

Advantages

1. Administration is comparatively inexpensive and easy even when gathering data


from large numbers of people spread over wide geographic area
2. Reduces chance of evaluator bias because the same questions are asked of all
respondents
3. Many people are familiar with surveys
4. Some people feel more comfortable responding to a survey than participating in an
interview
5. Tabulation of closed-ended responses is an easy and straightforward process

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

123
Computational mathematics………mathematics is a life style……live it…

3. Interviews

Is a meeting of people face to face, especially for consultation.

Advantages

1. Useful for gaining insight and context into a topic


2. Allows responds to describe what is important to them
3. Useful for gathering quotes and stories

Disadvantages

1. Time consuming
2. Expensive compared to other data collection methods
3. May seem intrusive to the respondents
4. Susceptible to interview bias

Types of data Classification


Some common types of classification are:

 Geographical i.e., according to area or region


 Chronological, i.e., according to occurrence of an event in time.
 Qualitative, i.e., according to attributes.
 Quantitative, i.e., according to magnitudes.

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.

Qualitative Classification: When the data is classified according to some attributes


(distinct categories) which are not capable of measurement is known as qualitative
classification, i.e. numbers are not used to record the data. In a simple (or dichotomous)
classification, as attribute is divided into two classes, one possessing the attribute and the

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

 Simple Tabulation or One-way Tabulation:


 Double Tabulation or Two-way Tabulation:
 Complex Tabulation:

Simple Tabulation or One-way Tabulation:


When the data are tabulated to one characteristic, it is said to be simple tabulation or one-
way tabulation.
For Example: Tabulation of data on population of world classified by one characteristic
like Religion is example of simple tabulation.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

125
Computational mathematics………mathematics is a life style……live it…

Double Tabulation or Two-way Tabulation:


When the data are tabulated according to two characteristics at a time. It is said to be
double tabulation or two-way tabulation.
For Example: Tabulation of data on population of world classified by two characteristics
like Religion and Sex is example of double tabulation.

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?

 Resources (time, money) and workload is reduced


 Gives results with known accuracy that can be calculated mathematically

Types of Samples
Probability (Random) Samples

 Simple random sample


 Systematic random sample
 Stratified random sample
 Multistage sample
 Multiphase sample
 Cluster sample

Non-Probability Samples

 Convenience sample
 Purposive sample
 Quota

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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.

Probability sampling includes:

 Simple Random Sampling,

 Systematic Sampling,

 Stratified Random Sampling,

 Cluster Sampling

Non probability sampling


Any sampling method where some elements of population have no chance of selection
(these are sometimes referred to as 'out of coverage'/'under covered'), or where the
probability of selection can't be accurately determined. It involves the selection of elements
based on assumptions regarding the population of interest, which forms the criteria for
selection. Hence, because the selection of elements is nonrandom, nonprobability sampling
not allows the estimation of sampling errors.

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.

Nonprobability Sampling includes:

 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…

Simple random sampling

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:

 Sample easy to select


 Suitable sampling frame can be identified easily
 Sample evenly spread over entire reference population

DISADVANTAGES:

 Sample may be biased if hidden periodicity in population coincides with that of


selection.
 Difficult to assess precision of estimate from one survey.

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.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

128
Computational mathematics………mathematics is a life style……live it…

Drawbacks to using stratified sampling.

 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

Cluster sampling is an example of 'two-stage sampling’. First stage a sample of areas is


chosen; Second stage a sample of respondents within those areas is selected. Population
divided into clusters of homogeneous units, usually based on geographical contiguity.
Sampling units are groups rather than individuals. A sample of such clusters is then
selected. All units from the selected clusters are studied.

Advantages:

 Cuts down on the cost of preparing a sampling frame.


 This can reduce travel and other administrative costs.
 Disadvantages: sampling error is higher for a simple random sample of same size.
 Often used to evaluate vaccination coverage in EPI

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

129
Computational mathematics………mathematics is a life style……live it…

Measure of central tendency

A measure of central tendency is a measure that tells us where the middle of a bunch of
data lies.

The most common measures of central tendency are

 Mean
 Median
 Mode
 Quartiles
 Percentiles
 Deciles

Mean
The mean is the average of the numbers.

Example 1

What is the Mean of these numbers?

6, 11, 7

Add the numbers: 6 + 11 + 7 = 24

Divide by how many numbers (there are 3 numbers): 24 / 3 = 8

The Mean is 8

Example 2:

Look at these numbers:

3, 7, 5, 13, 20, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29

The sum of these numbers is 330

There are fifteen numbers.

The mean is equal to 330 / 15 = 22

The mean of the above numbers is 22

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

130
Computational mathematics………mathematics is a life style……live it…

Example 3:

Find the mean of these numbers:

3, −7, 5, 13, −2

The sum of these numbers is 3 − 7 + 5 + 13 − 2 = 12

There are 5 numbers.

The mean is equal to 12 ÷ 5 = 2.4

The mean of the above numbers is 2.4

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

When we put those numbers in order we have:

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

The median value of this set of numbers is 23.

Two Numbers in the Middle


BUT, when there is an even amount of numbers things are slightly different.
In that case we need to find the middle pair of numbers, and then find the value that
would be half way between them. This is easily done by adding them together and dividing
by two.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

When we put those numbers in order we have:

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

In this example the middle numbers are 21 and 23.

To find the value half-way between them, add them together and divide by 2:

21 + 23 = 44
44 ÷ 2 = 22

So the Median in this example is 22.

How to Find the Mode or Modal Value

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

Ordering the numbers we get

3, 5, 7, 12, 13, 14, 20, 23, 23, 23, 23, 29, 39, 40, 56

This makes it easy to see which numbers appear most often.

In this case the mode is 23.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

132
Computational mathematics………mathematics is a life style……live it…

More Than One Mode

We can have more than one mode.

Example:

1, 3, 3, 3, 4, 4, 6, 6, 6, 9

3 appear three times, as does 6.

So there are two modes: at 3 and 6

Mean median and mode for ungrouped data

Mean
∑ 𝑓𝑥
Mean ( x ) =
∑𝑓

Example

The marks of seven students in an economics test out of a total of 20 marks are

Marks in Economics Number


fx
(out of 20) Students
19 1 19
18 3 54
15 4 60
13 2 26
17 5 85
12 4 48
11 1 11
∑ 𝑓 = 20 ∑ 𝑓𝑥 = 303

∑ 𝑓𝑥 303
Mean ( x ) = = = 15.15
∑𝑓 20

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

133
Computational mathematics………mathematics is a life style……live it…

Mode = 17

Median is between the 10th and 11th student

Arrange the data in ascending order

Marks in Economics Number c.f


(out of 20) Students
11 1 1
12 4 5
13 2 7
15 4 11
17 5 16
18 3 19
19 1 20
∑ 𝑓 = 20

15+15
Median = = 15
2

Mean median and mode for grouped data

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

134
Computational mathematics………mathematics is a life style……live it…

Mode

𝑓𝑖 − 𝑓𝑖−1 𝑓𝑖 − 𝑓𝑖−1
Mode = li + ( (𝑓𝑖 ) × ai = li + ( 2𝑓𝑖 ) × ai
− 𝑓𝑖−1)(𝑓𝑖 − 𝑓𝑖+1) − 𝑓𝑖−1 − 𝑓𝑖+1

li is the lower limit of the modal class.

fi is the absolute frequency of the modal class.

fi-1 is the absolute frequency immediately below the modal class.

fi+1 is the absolute frequency immediately after the modal class.

ai is the width of the class containing the modal class.

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

= 4.5 + 2.5 = 7.0

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

135
Computational mathematics………mathematics is a life style……live it…

Median
𝑁
− 𝑓𝑖−1
2
Median = li + × ai
𝑓𝑖

Where

Li is the lower limit of the median class.


𝑁
is half the sum of the absolute frequency.
2

fi-1 is the absolute frequency immediately below the median class.

ai is the width of the class containing the median.

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

136
Computational mathematics………mathematics is a life style……live it…

N-TILES

They include quartiles, deciles and percentiles.

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.

For a set of n observations,


𝐾
𝑁−𝑝 𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑐𝑢𝑚𝑢𝑙𝑎𝑡𝑖𝑣𝑒
4
QK = li +( )× C
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦

Deciles

Decile divides a set of data into 10 equal parts.


𝐾
𝑁 −𝑝 𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑐𝑢𝑚𝑢𝑙𝑎𝑡𝑖𝑣𝑒
10
DK = li +( )× C
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦

Percentile

Percentile divides a set of data into 100 equal parts.


𝐾
100
𝑁 −𝑝 𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑐𝑢𝑚𝑢𝑙𝑎𝑡𝑖𝑣𝑒
PK = li +( )× C
𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

137
Computational mathematics………mathematics is a life style……live it…

Example

Given the data below, find

Q1, Q3, D4, P65

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Mean Absolute Deviation(MAD)

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

Find the absolute deviation of the following data

57, 55, 62, 52, 54, 45, 57, 66

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

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

Variance and standard deviation

They are the most useful measures of variation for further statistical analysis

Variance is the mean of the squared deviations from the mean

Standard deviation is the square root of the variance

For ungrouped data


∑(𝑥𝑖− 𝑥 )2
Variance = 𝑛

∑(𝑥𝑖− 𝑥 )2
Standard deviation = √ 𝑛

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

141
Computational mathematics………mathematics is a life style……live it…

For grouped data, variance is given by


∑ 𝑓(𝑥𝑖− 𝑥 )2
Variance = ∑ 𝑓𝑖

∑ 𝑓(𝑥𝑖− 𝑥 )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

Standard deviation = √𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒 = √1862.78 = 43.16

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

142
Computational mathematics………mathematics is a life style……live it…

Skewness

Skewness is a measure of degree of asymmetry of the distribution.

1. Symmetric

Mean, median, and mode are all the same here; mound shaped, no skewness (symmetric).

The above distribution is symmetric.

2. Skewed Left (negative skewness )

Mean to the left of the median, long tail on the left.

The above distribution is skewed to the left.

3. Skewed Right (positive skewness)

Mean to the right of the median, long tail on the right.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

143
Computational mathematics………mathematics is a life style……live it…

The above distribution is skewed to the right.

Kurtosis

Is a measure of the peakedness of a distribution.

Fig. 1

Fig. 2

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

144
Computational mathematics………mathematics is a life style……live it…

Fig. 3

-Distribution having high peak as in fig. 1 is called leptokurtic.

-Distribution which is flat-topped as in fig. 3 is called platykurtic.

-Normal distribution which is not high peaked neither flat-topped as in fig. 2 is called
mesokurtic.

…..property of keiway mining and technology college………compiled by Mr. Mutuku………

145

You might also like