Understanding Number Systems in Computing
Understanding Number Systems in Computing
COLLEGE MURANG’A
MODULE I
COMPUTATIONAL MATHEMATICS
1
MR HILLARY ……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.
The decimal number system is used in general. However, the computers use binary number
system. The octal and hexadecimal number systems are used in the computer.
104 103 102 101 . 10-1 10-2 10-3 10-4 Power base
4 3 2 1 . 1 2 3 4 position
1 1 1 1 value
1000 100 10 1 . 10 100 1000 10000
2
MR HILLARY ……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
3
MR HILLARY ……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:23 = 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.
4
MR HILLARY ……mathematics is a life style……live it…
Types of data
➢ Numeric data
➢ Alphabetic data
➢ Alphanumeric data
Solution
1111001
For fraction numbers, the number is divided into two parts, the whole number part and the
fraction part.
The whole number part is converted as shown above.
The fraction part is repeatedly multiplied by 2, noting the complete units of two. The
process proceeds until the fraction becomes a zero or starts recurring.
5
MR HILLARY ……mathematics is a life style……live it…
Examples:
10100011.11
11001010.11100
6
MR HILLARY ……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.
26 25 24 23 22 21 20
1 1 1 1 0 0 1
64 + 32 + 16 + 8 + 0 + 0 + 1
12110
For the fraction part, digits are divided by multiples of two starting from the binary
point
24 23 22 21 20 . 2-1 2-2
1 1 0 1 0 . 0 1
1
16 + 8 + 0 + 2 + 0 + 0 +
4
26.2510
1 1 1 0 0 0 1 0 . 1 1 0 1
128 + 64 + 32 + 0 + 0 + 0 + 2 + 0 + 1 + 1 + 0 + 1
2 4 16
226.812510
7
MR HILLARY ……mathematics is a life style……live it…
Conversion from decimal to octal
You repeatedly divide the decimal number by 8.
Solution
12638
For fraction numbers, the number is divided into two parts, the whole part and the
fraction part.
Solutions
142.18
8
MR HILLARY ……mathematics is a life style……live it…
Example 2: convert 202.9 to octal
Solutions
312.714638
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.
9
MR HILLARY ……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.812510
Solutions
But A = 10
For fraction number, the fraction part is multiplied by 16 noting the complete units of 16’s.
Solutions
20.216
10
MR HILLARY ……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.
Solutions
161 160
7 A
112 + 10
12210
For fractional hexadecimal values, the division is by 16’s though the procedure is the same
as the binary fractions to decimal.
Solutions
2 0 . 2
32 + 0 + 2
16
32 + 0.125
32.12510
Negative numbers
Both negative and positive numbers can be represented in computer memory during
processing
11
MR HILLARY ……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.
1710 = 100012
-1710 = 011102
1710 = 100012
-1710 = 01110
+ 1
01111
Conventionally, a ‘1’ is used to represent a negative sign and a ‘0’ to represent a positive
sign.
The binary digits therefore will be having part of them representing the data while the
others the sign bit
12
MR HILLARY ……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.
13
MR HILLARY ……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
14
MR HILLARY ……mathematics is a life style……live it…
The subtraction can also be carried out using the complement and signed magnitude.
Add the overflow digit to the least significant bit of the sum to get the difference.
If the two’s complement method is used, the procedure looks a bit different but the
difference got is the same
15
MR HILLARY ……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
= 10 0 1 12
16
MR HILLARY ……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
17
MR HILLARY ……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
18
MR HILLARY ……mathematics is a life style……live it…
In the coding, when numbers, letters or words are represented by a specific group of
symbols, it is said that the number, letter or word is being encoded. The group of symbols
is called as a code. The digital data is represented, stored and transmitted as group of
binary bits. This group is also called as binary code. The binary code is represented by the
number as well as alphanumeric letter.
Binary codes are used to represent all members among a group of quantities differently
such that every element has a distinct code from any other element.
• Weighted Codes
• Non-Weighted Codes
• Sequential codes
• Alphanumeric Codes
• Reflective codes
• Error Detecting Codes
• Error Correcting Codes
19
MR HILLARY ……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
20
MR HILLARY ……mathematics is a life style……live it…
Excess-3 code
The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express
decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words
adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as
follows.
Example
21
MR HILLARY ……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.
22
MR HILLARY ……mathematics is a life style……live it…
For example:
For example
23
MR HILLARY ……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
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)
24
MR HILLARY ……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
25
MR HILLARY ……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
26
MR HILLARY ……mathematics is a life style……live it…
41 - 18 = 23
Example
51 – 21
51 + 78 = 129
The decimal result is then changed to BCD code to get the result
BCD subtraction using 10’s complement is the same as in case of 9’s complement, the
only difference is that instead of 9’s complement, we have to do 10’s complement of the
subtrahend. In 10’s complement, the carry is ignored.
Example
51 – 21
27
MR HILLARY ……mathematics is a life style……live it…
To get 10’s complement, we get the 9’s complement and add a 1.
51 + 79 = 130
BCD Multiplication
Multiply the two BCD numbers using the rules for binary multiplication. To adjust the
product divide it by decimal 10, then place the quotient in the most significant byte and the
remainder in the least significant byte (convert the binary answer to unpacked BCD).
Example
BCD Division
Before dividing a BCD number, the division adjustment is made by converting the BCD
numbers to binary. Adjust the two-byte BCD number by multiplying the upper byte by
decimal 10 and adding the product to the lower byte. After the adjustment, divide the two
binary numbers using the rules of binary arithmetic. Finally, convert the binary quotient
into a BCD number if necessary.
28
MR HILLARY ……mathematics is a life style……live it…
Example
Exercise
Alphanumeric codes
Alphanumeric codes are sometimes called character codes due to their certain properties.
Now these codes are basically binary codes. We can write alphanumeric data, including
data, letters of the alphabet, numbers, mathematical symbols and punctuation marks by this
code which can be easily understandable and can be processed by the computers. Input
output devices such as keyboards, monitors and mouse can be interfaced using these codes.
12-bit Hollerith code is the better known and perhaps the first effective code in the days of
evolving computers in early days. During this period punch cards were used as the
inputting and outputting data. But nowadays these codes are termed obsolete as many other
modern codes have evolved. The most common alphanumeric codes used these days are
ASCII code, EBCDIC code and Unicode.
Earlier computers were used only for the purpose of calculations i.e. they were only used
as a calculating device. But now computers are not just used for numeric representations,
they are also used to represent information such as names, addresses, item descriptions etc.
Such information is represented using letters and symbols. Computer is a digital system
and can only deal with l's and 0’s. So to deal with letters and symbols they use
alphanumeric codes.
29
MR HILLARY ……mathematics is a life style……live it…
i. ASCII code
The full form of ASCII code is American Standard Code for Information Interchange.
It is a seven bit code based on the English alphabet.
In 1967 this code was first published and since then it is being modified and updated.
ASCII code has 128 characters since it has 7 bits. These includes 95 printable characters
including 26 upper and 26 lower case letters, 10 numerals and 33 special characters such as
mathematical symbols etc. It also defines 33 non printable characters. They matched each
symbol with decimal position and each position was converted to binary to get their ASCII
code.
E.g. positions 48 – 57 was taken by decimal 0 – 9
Positions 65 – 90 was taken by upper case A – Z
Positions 97 – 122 was taken by lower case a – z
So if you want to get the ASCII code for 0, convert 48 to binary => 0110000 and ASCII
code for A, convert 65 to binary => 1000001
iii. UNICODE
Unicode is the newest concept in digital coding. In Unicode every number has a unique
character. Leading technological giants have adopted this code for its uniqueness. A part of
the Unicode table is given below.
Error detection
Error means a condition when output information is not same as input information. When
transmission of digital signals takes place between two systems such as a computer, the
transmitted signal is combined with the "Noise". The noise can introduce an error in the
binary bits travelling from one system to other. That means 0 may change to 1 or a 1 may
change to 0.
Whenever a message is transmitted then there are changes that it gets scrambled by noise
or data gets corrupted. When we add some additional data to a given digital message which
can help us to detect if an error occurred during transmission of the message then adding
such data is called an error-detecting code. A simple example of error-detecting code is
parity check.
30
MR HILLARY ……mathematics is a life style……live it…
Parity checking is a simple technique for detecting errors. In the MSB of an 8-bits word is
used as the parity bit and the remaining 7 bits are used as data or message bits. The parity
of 8-bits transmitted word can be either even parity or odd parity.
Even parity -- Even parity means the number of 1's in the given word including the parity
bit should be even (2,4,6, ).
Odd parity -- Odd parity means the number of 1's in the given word including the parity
bit should be odd (1,3,5, ... ).
• The parity bit can be set to 0 and 1 depending on the type of the parity required.
• For even parity this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is even. Show in the fig. (a).
• For odd parity this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is odd. Show in the fig. (b).
31
MR HILLARY ……mathematics is a life style……live it…
Parity bit –is an extra bit added to a data bits to make the number of ones in
the data even or odd.
The parity checking at the receiver can detect the presence of an error if the parity of the
receiver signal is different from the expect parity. That means if is known that the parity of
the transmitted signal is always going to be "even" and if the received signal has an odd
parity then the receiver can conclude that the received signal is not correct. If presence of
error is detected then the receiver will ignore the received byte and request for
retransmission of the same byte to the transmitter.
Disadvantages
NB: parity bit is only suitable for detecting errors. It cannot correct any errors as there is
no way to determine which particular bit is corrupted. Data must be discarded entirely and
re-transmitted again from scratch.
32
MR HILLARY ……mathematics is a life style……live it…
A logic gate is an electronic circuit that accepts one or more than one inputs and gives out
only one output. Logic gates are the basic building blocks of any digital system. The
relationship between the input and the output is based on certain logic.
➢ AND gate
➢ OR gate
➢ NOT gate
AND Gate
We can mimic the AND gate using the series connection
The bulb only lights when the two switches are on. The bulb will not light when any of the
switches is off.
The operation of AND gate is such that its output is a logic 1 only if all its output are logic
1. Otherwise the output is logic 0.
33
MR HILLARY ……mathematics is a life style……live it…
AND gate may have as many inputs as the gate may require. Regardless of the number of
inputs, all the inputs must be logic 1 for the gate to output logic 1. It has n input (n >= 2)
and one output.
Symbol
Truth table
input output
0 0 0
0 1 0
1 0 0
1 1 1
Application
OR Gate
We can mimic the OR gate using the
parallel connection
The bulb lights if any of the switches is closed. The bulb does not light only when all the
switches are off.
34
MR HILLARY ……mathematics is a life style……live it…
OR gate outputs logic 1 if any of its output is logic 1. It only outputs logic 0 if all of its
inputs are logic 0.
May have as many inputs as the gate may require but regardless of the number of inputs, if
any of the input is logic 1, the gate outputs logic 1.
Symbol
Truth table
input Output
0 0 0
0 1 1
1 0 1
1 1 1
Application
Car door alarm system. When all the doors are closed, 0000 is applied to the input of the
gate. When one or more gates are open, the output of OR gate is 1, which activates the
alarm.
NOT Gate
Has a single input. It changes logic 0 input to logic 1 output and logic 1 input to logic 0
output. It has n input (n >= 2) and one output.
Symbol
35
MR HILLARY ……mathematics is a life style……live it…
Truth table
input Output
0 1
1 0
Application
NOT gate is combined with AND gate and OR gate to come up with two other gates
➢ NAND gate
➢ NOR gate
NAND Gate
A NOT-AND operation is known as NAND operation. The NOT gate negates the output
from the AND gate. Hence NAND gate outputs a 1 if any input is a zero. It has n input (n
>= 2) and one output.
Symbol
36
MR HILLARY ……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
37
MR HILLARY ……mathematics is a life style……live it…
Application
➢ Exclusive- OR gate
➢ Exclusive-NOR gate
XOR Gate
XOR or Ex-OR gate is a special type of gate. The exclusive-OR gate is abbreviated as EX-
OR gate or sometime as X-OR gate. It has n input (n >= 2) and one output.
XOR gate is sometimes called a parity checker. Parity checkers count the number of ones
and being input and to a circuit and output logic 1 or 0 based on whether the number of
ones is odd or even.
The XOR gate count the number of 1’s at its input and outputs a logic 1 for an odd count
and logic 0 for an even count.
Symbol
Truth
input output
0 0 0
0 1 1
1 0 1
1 1 0
38
MR HILLARY ……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
39
MR HILLARY ……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
(A + B).(A + C)
40
MR HILLARY ……mathematics is a life style……live it…
Boolean Algebra
Boolean Algebra is used to analyze and simplify the digital (logic) circuits. It uses only the
binary numbers i.e. 0 and 1. It is also called as Binary Algebra or logical Algebra.
Boolean algebra was invented by George Boole in 1854.
• Variable used can have only two values. Binary 1 for HIGH and Binary 0 for
LOW.
• Complement of a variable is represented by an over bar (-). Thus complement of
variable B is represented as . Thus if B = 0 then = 1 and B = 1 then = 0.
• ORing of the variables is represented by a plus (+) sign between them. For example
ORing of A, B, C is represented as A + B + C.
• Logical ANDing of the two or more variable is represented by writing a dot
between them such as A.B.C. Sometime the dot may be omitted like ABC.
Boolean Laws
Addition multiplication
0+0=0 0.0=0
1+0=1 1.0=0
0+1=1 0.1=0
1+1=1 1.1=1
Commutative law
Commutative law states that changing the sequence of the variables does not have any
effect on the output of a logic circuit.
41
MR HILLARY ……mathematics is a life style……live it…
Associative law
This law states that the order in which the logic operations are performed is irrelevant as
their effect is the same.
Distributive law
A + (B.C) = (A+B).(A+C)
AND law
These laws use the AND operation. Therefore they are called as AND laws.
OR law
These laws use the OR operation. Therefore they are called as OR laws.
INVERSION law
This law uses the NOT operation. The inversion law states that double inversion of a
variable result in the original variable itself.
De-Morgan’s theorem
Exercise: Simplify
42
MR HILLARY ……mathematics is a life style……live it…
43
MR HILLARY ……mathematics is a life style……live it…
Algebra is a branch of mathematics that uses letters and other symbols instead of numbers.
E.g. x + y = z
QUADRATIC EQUATIONS
ax2+ bx +c = 0
❖ Factorization
❖ Completing square method
❖ Quadratic formula
❖ Graphical method
Factorization method
Quadratic equations are of the form ax2+ bx +c = 0. To solve using factorization method;
Example
44
MR HILLARY ……mathematics is a life style……live it…
Solution
= 2x(x + 5) – 3(x + 5) = 0
= (2x - 3)(x + 5) = 0
= 2x – 3 = 0 or x + 5 = 0
= 2x = 3 or x = -5
=x=3 or x = -5
2
Exercise
Solve by factorization
1. 6x2 – 13x + 6 = 0
2. x2 – 8x – 20 = 0
3. 35x2 – x – 12 = 0
4. 2x2 – 5x + 3 = 0
It is called this because it uses a process called completing the square in the solution
process. So, we should first define just what completing the square is.
x2 + bx
45
MR HILLARY ……mathematics is a life style……live it…
This process is called completing the square and if we do all the arithmetic correctly we
can guarantee that the quadratic will factor as a perfect square.
Example
Solve 5x2 – 6x – 2 = 0
Solutions
x2 - 6 x - 2 = 0
5 5
x2 - 6 x = 2
5 5
6 1 2 6 1 2
x2 - 6 x + (− × ) = 2 + (− × )
5 5 2 5 5 2
36
(x- 6 )2 = 2
+
10 5 100
36 19
( x - 3 )2 = 2
+ =
5 5 100 25
( x - 3 )2 = 19
5 25
19
x-3 =± √
5 25
3 19
x = ± √
5 25
x = 3 ± √19
5
3 + √19 3− √19
x= or x =
5 5
46
MR HILLARY ……mathematics is a life style……live it…
Exercise
➢ 2x2 – 6x -1 = 0
➢ x2 + 7x – 3 = 0
➢ -7 + 12x – 3x2 = 0
Quadratic formula
= x2 + 𝑏 x = - 𝑐
𝑎 𝑎
x2 + 𝑏 x + ( 𝑏 )2 = - 𝑐 + ( 𝑏 )2
𝑎 2𝑎 𝑎 2𝑎
(x+ 𝑏 )2 = - 𝑐 + 𝑏2
2𝑎 𝑎 4𝑎2
𝑏 −4𝑎𝑐 + 𝑏2
(x+ )2 =
2𝑎 4𝑎2
−4𝑎𝑐 + 𝑏2
𝑏 = ±√
x + 2𝑎 4𝑎2
−4𝑎𝑐 + 𝑏2
x =- 𝑏 ±√
2𝑎 4𝑎2
− 𝑏 ± √𝑏2 −4𝑎𝑐
x =
2𝑎
Example
3x2 – 7x – 1 = 0
47
MR HILLARY ……mathematics is a life style……live it…
Solutions
− 𝑏 ± √𝑏2 −4𝑎𝑐
x =
2𝑎
a = 3, b = -7, c = -1
7 ± √49+12
x =
6
7 ± √61
x =
6
7 + √61 7− √61
x = or x =
6 6
Exercise
5x2 + 3x – 7 = 0
4 + 13y + y2
Graphical method
Steps
Example
x2 – 3x + 2 = 0
in the interval -2 ≤ x ≤ 3
48
MR HILLARY ……mathematics is a life style……live it…
solution
x -2 -1 0 1 2 3 4 5
y 12 6 2 0 0 2 6 12
14
12
10
0
-4 -2 0 2 4 6
-2
Solution x = 1 or x = 2
Exercise:
1. x2 – 6x + 6 = 0
2. 4x2 – 25x + 28 = 0
MATRIX
Some definitions:
49
MR HILLARY ……mathematics is a life style……live it…
Column matrix (column vector)
Rectangular matrix
A matrix who’s the number of rows is not equal to the number of columns.
Square matrix
Singular matrix
This is a matrix that has a matrix inverse. I.e. its determinant is not 0(zero).
Null matrix
Identity matrix
Is a square matrix with ones on the main diagonal and zeros elsewhere.
Denoted by In or I.
1 0 0
Example: 3 by 3 identity matrix 0 1 0
0 0 1
50
MR HILLARY ……mathematics is a life style……live it…
Matrix operations
Addition
𝑎 𝑏 𝑤 𝑥 𝑎+𝑤 𝑏+𝑥
+ 𝑦 =
𝑐 𝑑 𝑧 𝑐+𝑦 𝑑+𝑧
Example:
−2 6 3 7 1 13
3 −5 + −4 3 = −1 −2
4 −8 0 2 4 −6
Subtraction
𝑎 𝑏 𝑤 𝑥 𝑎−𝑤 𝑏−𝑥
- =
𝑐 𝑑 𝑦 𝑧 𝑐−𝑦 𝑑−𝑧
3 −4 −1 7 4 −11
Example: 0 7 - 4 −2 = −4 9
−4 1 0 2 −4 −1
N/B: To add and subtract a matrix, they must be of the same size.
Multiplication:
• scalar multiplication
• matrix multiplication.
51
MR HILLARY ……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.
A= 1 2
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
2A = 2. 4
=
3 4 2.3 2.4 6 8
Matrix multiplication
• The number of columns of the 1st matrix must equal the number of rows of the
2nd matrix.
• And the result will have the same number of rows as the 1st matrix, and the same
number of columns as the 2nd matrix.
N/B: before you multiply matrices, make sure they are compatible i.e. the number of
elements in the row of the first matrix must be equal to the number of elements in the
column in the second matrix.
Example:
1 0 −2 0 3
A = , B = −2 −1
0 3 −1
0 4
0 3
1 0 −2
Then AB = −2 −1 =
0 3 −1
0 4
52
MR HILLARY ……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
• 2 by 2 matrix
𝑤 𝑥
Given matrix A = [ 𝑦 𝑧] , then its determinant is obtained as follows;
Det = wz – xy
• 3 by 3 matrix
𝑎 𝑏 𝑐
Given matrix A = 𝑑 𝑒 𝑓 , then determinant is obtained as follows;
𝑔 ℎ 𝑖
𝑒 𝑓 𝑑 𝑓 𝑑 𝑒
Det = a| | + b| | + c| |
ℎ 𝑖 𝑔 𝑖 𝑔 ℎ
3 0 2
Example. A = 2 0 −2
0 1 1
= 6 + 0 + 4 = 10
10
53
MR HILLARY ……mathematics is a life style……live it…
Determining the inverse of a matrix
• 2 by 2 matrix
Steps:
3 2
Example: find the inverse of the matrix A = [ ]
−1 −2
1 1
1 −2 −2 1 −2 −2 2 2
= [ ]=- [ ] = [ ]
𝑑𝑒𝑡 1 3 4 1 3 1 3
− −
4 4
• 3 by 3 matrix
➢ Co-factor method
➢ Row reduction method
Co-factor method
Steps:
54
MR HILLARY ……mathematics is a life style……live it…
3 0 2
A= 2 0 −2
0 1 1
3 0 2
2 0 −2
0 1 1
0 −2 2 −2 2 0
Then det = 3| | + 0| | + 2| |
1 1 0 1 0 1
= 6 + 0 + 4 = 10
10
3 0 2
2 0 −2
0 1 1
0 −2
= | |
1 1
2 −2
= | |
0 1
55
MR HILLARY ……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
56
MR HILLARY ……mathematics is a life style……live it…
3 0
= | |
2 0
|0 −2 2 −2 2 0
| | | | |
1 1 0 1 0 1
0 2 3 2 3 0
| | | | | |
1 1 0 1 0 1
|0 2 | |3 2 | |3 0
|
0 −2 2 −2 2 0
(0 − −2) (2 − 0) (2 − 0)
= (0 − 2) (3 − 0) (3 − 0)
(0 − 0) (−6 − 4) (0 − 0)
2 2 2
= −2 3 3
0 −10 0
2 2 2 + − + 2 −2 2
−2 3 3 − + − = 2 3 −3
0 −10 0 + − + 0 10 0
57
MR HILLARY ……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
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
= − 1 or −0.2 0.3 1
5 10
1 3 0.2 −0.3 0
− 0
5 10
An n×n square matrix A is called invertible if there exist matrix X such that;
AX = XA = I (identity)
If that matrix exist, it is unique. We call it the inverse of A and denoted by A-1 = X, so that;
A.A-1 = A-1.A = I
58
MR HILLARY ……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
1 2 3 1 2 3
Eg. 4 5 6 R2π 4𝜋 5𝜋 6𝜋
7 8 9 7 8 9
1 2 3 1 2 3
Eg. 4 5 6 R2 = R2 – 4R1 0 −3 −6
7 8 9 7 8 9
Row reduction is a process of using row operations to reduce a matrix to a row reduced
Echelon form.
❖ The first non-zero element (leading coefficient), if any in each row, must be 1.
❖ Each leading coefficient is the only non-zero element in its column.
❖ All the zero rows if any are at the bottom of the matrix
❖ The leading coefficient forms a stair-step pattern from northwest to the southeast.
59
MR HILLARY ……mathematics is a life style……live it…
Examples:
1 0 0
0 5 0 No because the leading coefficient in second row is not 1.
0 0 1
1 0 0
0 1 6 No because 1 is not the only non-zero element in that row 3
0 0 1
1 1 −1
1. 2 −1 1
1 1 2
1 −1 2
2. −3 3 −1
2 −1 0
➢ Cramer’s rule
➢ Inverse method
➢ Row reduction method (Gaussian elimination)
60
MR HILLARY ……mathematics is a life style……live it…
Cramer’s Rule
Two equations
a1x + b1y = d1
a2x + b2y = d2
𝐷𝑥 𝐷𝑦
x= and y =
𝐷 𝐷
Example
3x + 4y = -14
-2x – 3y = 11
61
MR HILLARY ……mathematics is a life style……live it…
Solution
𝐷𝑥 −2
x= = = 2
𝐷 −1
𝐷𝑦 5
y= = -5
𝐷 −1
therefore, x = 2, y = -5
Three equations
62
MR HILLARY ……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
63
MR HILLARY ……mathematics is a life style……live it…
Solution
x = 3 =1 , y = −6 = -2 , z = 9 =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)
64
MR HILLARY ……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
(ans: x = − , y = 1 , z = 0)
3 3
Inverse method
E.g.
x + 2y = 4
3x – 5y = 1
1 2 𝑥
=( ( 4
3 −5 ) 𝑦 ) = ( 1)
1 2 𝑥
Writing A= ( ) , X=( ) and B = ( 4)
3 −5 𝑦 1
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.
65
MR HILLARY ……mathematics is a life style……live it…
A is called the matrix of coefficient.
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
( )( )= (4)
3 −5 y 1
1 2
Inverse matrix of A = ( )
3 −5
A-1 = 1 −5 −2
( )
1(−5)−(2×3) −3 1
- 1
(−5 −2)
11 −3 1
X = A-1B = - 1
(−5 −2) (4)
11 −3 1 1
- 1 ( −22 ) = ( 2 )
11 −11 1
X = 2, y = 1
66
MR HILLARY ……mathematics is a life style……live it…
Exercise
1. 5x + y = 13
3x + 2y = 5
(ans: x = 3, y = -2)
2. 3x + 2y = -2
x + 4y = 6
(ans: x = -2, y = 2)
NB: It is much more tedious to use the inverse matrix to solve a system of 3 equations
although in principle, the method is the same as for two equations.
Example 1:
x + 5y = 7
−2x – 7y = −5.
Solution:
We carry out the elimination procedure on both the system of equations and the
corresponding augmented matrix, simultaneously. In general only one set of reductions is
necessary, and the latter (dealing with matrices only) is preferable because of the
simplified notation.
x + 5y = 7
−2x – 7y = −5
1 5 7
= ( )
−2 −7 −5
67
MR HILLARY ……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:
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
68
MR HILLARY ……mathematics is a life style……live it…
2y + z = −8
x – 2y – 3z = 0
−x + y + 2z = 3
0 2 1 −8
=( 1 −2 −3 0)
−1 1 2 3
Swap Row 1 and Row 2.
x – 2y – 3z = 0
2y + z = −8
−x + y + 2z = 3
1 −2 −3 0
=( 0 2 1 −8)
−1 1 2 3
x – 2y – 3z = 0
2y + z = −8
−y−z=3
1 −2 −3 0
=( 0 2 1 −8)
0 −1 −1 3
Swap Row 2 and Row 3.
x – 2y – 3z = 0
−y−z=3
2y + z = −8
1 −2 −3 0
=( 0 −1 −1 3)
0 2 1 −8
69
MR HILLARY ……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
x – 2y = 6
−y =5
− z = −2
1 −2 0 6
=( 0 −1 0 5)
0 0 −1 −2
x = −4
−y=5
− z = −2
1 0 0 −4
=( 0 −1 0 5)
0 0 −1 −2
70
MR HILLARY ……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:
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
71
MR HILLARY ……mathematics is a life style……live it…
Add −2 times Row 1 to Row 2.
x – 2y6 – 6z = 12
− 2y− 6z = 10
0 = −1
72
MR HILLARY ……mathematics is a life style……live it…
Out-put vector of the economy
Leontief model
➢ There should be enough of each good to meet the demand for it.
➢ There should be no "leftovers", i.e., unused goods.
In a real economy there are tens of thousands of different goods and services, but we can
often simplify matters by combining goods into categories. For example, let us consider a
very simple economy that runs on just 3 different types of output: raw materials, services,
and manufacturing. Raw materials include the output of many different industries,
agriculture and mining to name two. Services include retailing, advertising, transportation,
etc.
Now, the raw materials industry needs some of the output from the other two industries to
do its job. For example, it needs trucking to get its goods to market, and it uses some
manufactured goods (machines.) The raw materials industry even needs some of its own
output to produce its own output - iron ore to make the steel to build the rails that carry ore
from the mines, for example.
Similarly, each of the other two industries requires some amount of output from each of
the three to do its job. All of these requirements can be summarized in the form of a table
such as the following:
The numbers in the table tell how much output from each industry a given industry
requires in order to produce one dollar of its own output. For example, to provide $1
worth of service, the service sector requires $.05 worth of raw materials, $.03 worth of
services, and $.01 worth of manufactured goods.
The information in the table can be more compactly described by dropping the headings.
The result is a 3x3 matrix called the input-output matrix:
73
MR HILLARY ……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.
74
MR HILLARY ……mathematics is a life style……live it…
NB: In the inter-industry matrix, a column entry typically represents inputs to an industrial
sector, while a row entry represents output from a given sector.
Example:
An economy has the two industries R and S. The current consumption is given by the table
consumption
R S External
Industry R production 50 50 20
Industry S production 60 40 100
Assume the new external demand is 100 units of R and 100 units of S. Determine
Solution:
The total production is 120 units for R and 200 units for S. We obtain
50 50
20 ) ,
X = (120 ) A = (120 200 / 100
, B= ( 60 40 ) , and B = ( )
200 100 100
120 200
The solution is
1
X/ = (I2 - A)-1B/ = (96 30 ) ( 100 ) = ( 307.3 )
41 60 70 100 317.0
The new production levels are 307.3 and 317.0 for R and S, respectively.
Cryptography involves encrypting data so that a third party cannot intercept and read the
data.
In the early days of satellite television, the video signals were not encrypted and anyone
with a satellite dish could watch whatever was being shown, so the satellite dish owners
were able to get/receive their satellite feeds for no cost while the cable subscribers had to
pay for the channel. They were losing money.
75
MR HILLARY ……mathematics is a life style……live it…
So, they started encrypting the video signals with a system called video cipher. What the
video cipher encryption system did was to convert the signal into digital form, encrypt it,
and send the data over the satellite. If the satellite dish owner had a video cipher box, and
paid for the channel, then the box would descramble (encrypt) the signal and return it to its
original, useful form.
This was done using a key that was invertible. It was very important that the key be
invertible, or there would be no way to return the encrypted data to its original form
Encryption process
Example
Consider the message “RED RUM”. A message is converted into numerical form according
to some scheme. The easiest scheme is to let space = 0, A = 1, B = 2, C = 3, ................. , Y =
25, Z = 26. For example the message “RED RUM” would become 18, 5, 4, 0, 18, 21, 13.
This data is placed into matrix form. The size of the matrix depends on the size of the
encryption key. Let’s say that our encryption matrix (encoding matrix) is 2 by 2 matrixes.
Then:
18 5
A=(4 0)
18 21
3 0
There is an invertible matrix which is called encryption matrix or the encoding matrix.
let’s call it B
4 −2
B=( )
−1 3
The encrypted data is then multiplied by our encoding matrix. The result of this
multiplication is the matrix containing the encrypted data.
67 −21
AB = (16 −8 )
51 27
52 −26
MR HILLARY………mathematics is a life style……live it…
76
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”
−1 5 −1
Using encryption matrix B = (−2 11 7) encrypt message “I LOVE MONICA”.
1 −5 2
Write the stream of numbers that will be send.
Storage of information
E.g. A {a,b,c}
If a is an element of A, we denote as a∈ A.
A set is called finite if it contains finite number of elements. If a set is not finite, it is
called infinite.
Cardinality
Types of sets
1) subset
2) Equal sets
Two sets, A and B, are equal, denoted A=B, if and only if all element in A
belongs to the set B and every element in B belongs to set A, i.e.
A ⊆ B and A ⊇ B.
3) Proper subset
equal A.
4) Empty set
6) Universal set
Venn diagram
Union
The union of sets A and B, denoted A ∪ B, is the set containing all elements in either A or
B or both. i.e.
A ∪ B = {γ : γ ∈ A or γ ∈ B}.
A ∩ B = {1, 3, 4, 5, 6, 7, 8}
Intersection
The intersection of sets A and B, denoted A ∩ B, is the set containing all elements in both
A and B. i.e.
A ∩ B = {γ : γ ∈ A and γ ∈ B}.
Example
A∩B = {3, 5}
Difference
The difference of A and B is denoted as A\B i.e. elements in A and not in B. Also B\A are
elements in B and not in A. The diagrams below shows the shaded region for A − B and
B−A
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
Let U = {a, b, c, d, e, f}, A = {a, c}, B = {b, c, f}, C = {b, d, e, f}. Then
B∪C = {b, c, d, e, f}
A∩ (B∪C) = {c}
A/ = {b, d, e, f} = C
Exercise
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.