Tutorial on Number Systems Q(1) (a) Convert the following octal and hexadecimal numbers to binary numbers And check your answers. (i) 1238 , and (ii) AD.1C16 . Confirm your answer in the decimal system. Must remember the 3-bit code and the 4-bit code. (i) 1238 1 2 38 001 010 0112 1238 10100112 Check 1238 10100112 1 2 6 1 2 4 1 21 1 2 0 64 16 2 1 8310 while 1238 1 8 2 2 81 3 8 0 64 16 3 8310 (ii) AD.1C16 = A 1010 D 1101 . . 1 0001 C16 1100 AD.1C16 10101101.0001112 . Check AD.1C16 10101101.0001112 1 2 7 1 25 2 3 2 2 2 0 2 4 2 5 2 6 128 32 8 4 1 0.0625 0.03125 0.015625 173.10937510 Also AD.1C16 10 161 13 16 0 1 16 1 12 16 2 1 12 160 13 2 173 0.0625 .046875 16 16 =173+0.109375 173.10937510 which checks with above. 1 Q(2) Convert the octal number 74138 to hexadecimal and confirm your answer. Solution Must remember code 4bit Binary code Decimal 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 10—A 1011 11---B 1100 12---C 1101 13---D 1110 14---E 1111 15---F Now 74138 111 100 001 0112 in groups of three bits. 1111 0000 10112 in groups of four bits. F 0 B16 . Check 74138 7 8 3 4 8 2 1 81 3 8 0 3584 256 8 3 385110 while F 0 B16 F 16 2 0 161 B 16 0 15 16 2 0 161 11 1 3840 0 11 385110 which checks. Also note 111 100 001 0112 1 211 1 210 1 2 9 1 2 8 0 2 7 0 2 6 0 2 5 0 2 4 1 2 3 0 2 2 1 21 1 2 0 2048 1024 512 256 8 2 1 385110 2 Alternative method (longer) 74138 7 8 3 4 8 2 1 81 3 8 0 7 512 4 64 8 3 = 3584 256 11 385110 Now 16 |3851 ____ 16| 240 ____ 16| 15 _____ 16| 0 So 74138 F 0 B16 11 -- B 0 -- 0 15 --F Thus 74138 385110 F 0 B16 . 3 Q3 (a) Convert 31 and 46 to binary form. (b) Convert the following octal and hexadecimal numbers to decimal. (i) 603.258 (ii) 2FA.816 (c) Convert the following binary number to octal and hexadecimal forms respectively. Check your answer by converting the 3 numbers to decimal. 1110100110 Solution (a) 2 31 1 2 15 1 2 7 1 2 3 1 2 1 0 1 So going backwards we get 3110 111112 Check 3110 1 2 4 1 2 3 1 2 2 1 21 1 2 0 16 8 4 2 1 =31. 2 46 0 2 23 1 2 11 1 2 5 1 2 2 0 21 1 0 So going backwards we get 4610 101110 2 Check 4610 1 2 5 0 2 4 1 2 3 1 2 2 1 21 0 2 0 =32 +0+8+4+2+0=32+14=46 4 (b) 603.258 6 8 2 0 81 3 8 0 2 8 1 5 8 2 2 5 384 0 3 391 0.25 0.078125 8 64 387.32812510 . 2FA.816 2 16 2 F 161 A 16 0 8 16 1 8 512 15 16 10 1 16 512 240 10 0.5 762.5 (c) 1110100110 2 1 110 100 110 2 1 6 4 6 8 remembering 3-bit code. 1110100110 2 0011 1010 0 110 2 inserting 2 zeros at beginning 3 A 616 remembering 4-bit code. Confirmation 1110100110 2 1 2 9 1 2 8 1 2 7 0 2 6 1 2 5 0 2 4 0 2 3 1 2 2 1 21 0 2 0 . 512 256 128 0 32 0 0 4 2 0 93410 . 1646 8 1 8 3 6 8 2 4 81 6 8 0 512 384 32 6 93410 . 3 A616 3 16 2 10 161 6 16 0 768 160 6 93410 which verifies are answers. 5 Tutorial on Matrices Q(1) 1 3 2 1 find AB, BA , A B, and ( A B) 2 . and B (a)If A 4 5 2 4 2 2 Show that ( A B) A B 2 AB BA . Why is ( A B) 2 A2 2 AB B 2 ? Solution 1 15 10 16 1 3 2 1 2 12 = . Q(1)(a) AB 2 4 4 5 4 16 2 20 20 18 6 4 0 10 2 1 1 3 2 2 . BA 4 5 2 4 4 10 12 20 14 8 1 3 2 A B 2 4 4 3 4 3 A B 2 6 9 6 1 3 4 . 5 6 9 4 9 24 12 36 15 48 9 18 54 24 81 72 57 3 12 5 15 1 3 1 3 1 6 . A 2 2 4 2 4 2 8 6 16 10 10 25 0 7 2 1 2 1 4 4 . B 2 4 5 4 5 8 20 4 25 28 21 7 5 15 10 16 0 10 0 A 2 AB BA B 2 10 10 20 18 14 8 28 21 15 16 10 7 15 48 5 10 0 0 10 20 14 28 10 18 8 21 72 57 2 A B Hence A B A 2 AB BA B 2 and A B A 2 2 AB B 2 since AB BA . N.B. Matrix multiplication is non-commutative. 2 2 6 Q(2) (a) 1 2 1 3 2 1 Show that if A 2 3 1 then B 4 3 1 and hence 2 0 1 6 4 1 find (i) AB and (ii) BA Q(2) Solution 1 2 1 3 2 1 1 (i) AA 2 3 1 4 3 2 0 1 6 4 1 1(2) 2(3) 1(4) 1(1) 2(1) 1(1) 1(3) 2(4) 1(6) 2(3) 3(4) 1(6) 2(2) 3(3) 1(4) 2(1) 3(1) 1(1) 2(3) 0(4) 1(6) 2(2) 0(3) 1(4) 2(1) 0(1) 1(1) 1 3 8 6 2 6 4 1 2 1 1 0 0 6 12 6 4 9 4 2 3 1 0 1 0 6 0 6 4 0 4 2 1 0 0 1 3 2 1 1 2 BA 4 3 1 2 3 6 4 1 2 0 (3)1 (2)( 2) (1)( 2) 3(2) (2)(3) (1)0 4(1) 3(2) 1(2) (4)2 3(3) 1(0) 6(1) (4)2 (1)( 2) 6(2) (4)(3) (1)0 1 1 1 66 3 2 1 1 0 0 3 4 2 4 6 2 8 9 4 3 1 0 1 0 6 8 2 12 12 6 4 1 0 0 1 Here matrix multiplication is commutative. 7 3(1) (2)1 (1)1 (4)1 3(1) 1(1) 6(1) (4)(1) (1)1 Q(3) 4 5 1 0 (a)If A 2 0 and B 0 7 evaluate 6 3 2 5 (i) A B , (ii) B A , (iii) AB and (iv) 5B . (b)Find AB where 1 3 3 7 3 3 A 1 4 3 and B 1 1 0 . 1 3 4 1 0 1 5 6 14 23 18 7 1 and P find C QP . (c)Given the matrix Q 4 5 5 16 15 18 13 Q(3)Solution (a) 4 5 A 2 0 6 3 1 0 B 0 7 2 5 4 1 5 0 3 5 07 2 7 (i) A B 2 0 6 2 3 5 4 2 1 4 0 (5) 5 5 7 0 2 7 (ii) B A 0 2 2 (6) 5 3 8 8 (iii) AB is not possible since the order of A is 3 2 while the order of B is 3 2 that is the number of columns of A number of rows of B . 0 1 0 5 7 0 35 (iv) 5B 5 0 2 5 10 25 8 1 3 3 7 3 3 7 3 3 3 3 0 3 0 3 (b) AB 1 4 3 1 1 0 = 7 4 3 3 4 0 3 0 3 1 3 4 1 0 1 7 3 4 3 3 0 3 0 4 1 0 0 = 0 1 0 . 0 0 1 . (c) matrix C QP is given by 5 6 14 23 18 7 1 C QP 4 5 5 16 15 18 13 5(14) 6(5) 5(23) 6(16) 5(18) 6(15) 5(7) 6(18) 5(1) 6(13) = 4(14) 5(5) 4(23) 5(16) 4(18) 5(15) 4(7) 5(18) 4(1) 5(13) 100 211 180 143 83 . C 81 172 147 118 69 9 Q(4) 1 2 3 7 8 9 7 8 , B and C (a)If A 4 5 6 10 11 12 9 10 compute (i) A B , (ii) A C and (iii) 3B . 1 7 4 0 2 , E , F and G 3 9 (b) If D 5 11 2 1 8 compute (i) DE , (ii) FD and (iii) GF . 3 13 9 5 6 7 and the matrix H P 15 16 12 27 5 6 find C HP . (c) If 10 1 2 3 7 8 9 6 6 6 4 5 6 10 11 12 6 6 6 Q(4)Solution (a) (i) A B (ii) A C is not possible as A is a 2 3 matrix while C is a 2 2 matrix. 21 24 27 . (iii) 3B 30 33 36 1(0) 7(1) 18 7 1 7 4 0 1(4) 7(2) . (b) (i) DE 5 11 2 1 4(5) 11(2) 5(0) 11(1) 2 11 (ii) FD is not possible since F is a 2 1 matrix and D is a 2 2 matrix. 2 (iii) GF 3 9 3(2) (9)( 8) 6 72 78 . 8 (c) 3 13 9 5 . P 15 16 12 27 we get 6 7 3 13 9 5 123 190 138 219 . C HP 5 6 15 16 12 27 105 161 117 187 11 Q(5)Consider the following matrices 2 1 3 2 a 2b , B , C , A 3 2 1 4 3c d a x D , E x y , F , y b 2 4 1 2x y 2 3 4 and J . G 3 2 4 , H y z 1 4 2 1 3 2 (a) If possible perform the following calculations (i) A C , (ii) J C , (iii) C D , (iv) A H , 1 (v) 2C B , (vi) G . 2 (b) If possible perform the following calculations (i) AC , (ii) JC , (iii) CJ , (iv) EB and (v) BE . 12 Solution Q(5) Solution 2 1 a 2b 2 a 1 2b . (a) (i) A C 3 2 3 c d 3 3 c 2 d (ii) J C is not possible since order of matrix J is 2 3 while C is of order 2 2. (iii) C D is not possible since order of matrix C is of order 2 2 while D is 2 1 matrix. 2 1 2x y 2 2x 1 y (iv) A H 3 2 y z 3 y 2 z a 2b 3 2 2a 3 4b 2 . (v) 2C B 2 3c d 1 4 6c 1 2d 4 1 2 4 1 1 1 3 (vi) G 3 2 4 2 2 2 1 3 2 1 2 1 2 2. 1 2 1 3 2 2 1 a 2b 2a 3c 4b d . (b)(i) AC 3 2 3c d 3a 6c 6b 2d (ii) JC is not possible since J is a 2 3 while C is a 2 2 matrix. a 2b 2 3 4 2a 2b 3a 8b 4a 4b . (iii) CJ 3c d 1 4 2 6c d 9c 4d 12c 2d 3 2 3x y 2 x 4 y . y 1 4 (v) BE is not possible since B is a 2 2 matrix while E is a 1 2 matrix. (iv) EB x 13 Tutorial on Matrices or Arrays-Storing and manipulating data Example 1 A distributor records the weekly sales of personal computers(PC’s) in three retail outlets in different parts of the country and given in Table below. Shop A Shop B Shop C Number of computers sold in each shop Pentium(basic) Pentium(special) 150 320 170 420 201 63 Pentium(latest) 180 190 58 The cost price of each model is Pentium(basic) €480, Pentium(special) €600 and Pentium(latest) €1020. The retail price of each model in each of the three shops is given in Table below. Shop A Shop B Shop C Selling Price of computers in each shop Pentium(basic) Pentium(special) 560 750 520 690 590 720 Pentium(latest) 1580 1390 1780 Use matrix multiplication to calculate (a) Total weekly cost of computers to each shop. (b) Total weekly revenue of each model for each shop (c) Total weekly profit for each shop. Whish shop makes the greatest overall profit? Solution (a) The number sold may be written in a matrix Q 150 320 180 Q 170 420 190 201 63 58 and the cost of each type of computer ca be written as a column matrix C 480 C 650 1020 14 150 320 180 480 Hence Total cost QC 170 420 190 650 201 63 58 1020 150 480 320 600 180 1020 447600 170 480 420 600 190 1020 527400 201 480 63 600 58 1020 193440 Total cost of computers in Shop A =£447600, Total cost of computers in Shop B =£527400, Total cost of computers in Shop C =£193440. (b) Total revenue=price quantity Quantities are given by matrix Q and prices from Table . Matrix multiplication is carried out by muptiplying rows columns.Hence to multiply quantity price for each computer, the rows of table must be written as columns in a price matrixThat is the price matrix must be transposed before premultiplying by the quantities matrix Q . T 560 520 590 560 750 1580 P 520 690 1390 750 690 720 590 720 1780 1580 1390 1780 Multipy Q by P 150 320 180 560 520 590 QP 170 420 190 750 690 720 201 63 58 1580 1390 1780 Shop A Shop B Shop C NA NA 150 560 320 750 180 1580 NA 170 520 420 690 190 1390 NA NA NA 201 590 63 720 58 1780 The total revenue for each shop is given by the elements on the main diagonal. 15 84000 240000 284000 604400 Total Revenue 88400 289800 264100 642300 118590 45360 103240 267190 604400 447600 156800 (c) Profit=Total Revenue-Total Cost= 642300 527400 114900 . 267190 193440 73750 Shop A has the largest profit. 16 Tutorial on functions Exercise Let f : (, ) (, ) where f is given by 28x-7y=-70. Is this a function? Draw its graph and state its domain, co-domain and range. Solution Rewriting 28 x 7 y 70 7 y 28 x 70 y 4 x 10 . Its domain is (, ) ,its co-domain is (, ) and its range is (, ) . Yes it is a function as every real number in its domain (, ) is mapped to an element of its co-domain (, ) e.g. x (, ) is mapped to real number y 4 x 10 (, ) . Its domain is (, ) ,co-domain (, ) and range (, ) . Its graph is given below. Graph of linear function y=4x+10 20 15 10 4x 10 5 0 5 10 10 5 0 5 10 x 17 15 20 Exercise Consider the function f : 1,2,3 a, b, cgiven by f (1) a, f (2) b and f (3) c . Draw its arrow diagram and state its domain, codomain and range. Is it (i) onto and (ii) one-to-one ? Explain. Does it have an inverse f 1 and if so what is it ? Solution Arrow diagram of f 1 a 2 b 3c domain 1,2,3 codomain a, b, c range a, b, c. f is onto since rangea, b, c = codomaina, b, c , It is one-to-one as no two distinct elements of the domain have the same image,since f (1) a, f (2) b and f (3) c . Now since f is (i) onto and (ii)one-to-one then by theorem by the above function f has an inverse f 1 and it is given by f 1 : a, b, c 1,2,3where f 1 (a) 1 f 1 (b) 2 f 1 (c) 3 . You just reverse the process. 18 Exercise Are the following (i) f : A, B, C 11,12,13where f ( A) 11, f ( B) 13 (ii ) g : A, B, C 11,12,13where g ( A) 11, g ( B) 13, g (C ) 13 (iii) h : A, B, C 11,12,13where h( A) 11, h( B) 13, h(C ) 12 functions. Give your reasons. For the ones that are functions give their domain, codomain and range. Are they onto and one-to-one .Do the have an inverse and if so what is it. Solution (i) f is not a function since not every element of the domain is mapped to an element of the codomain, for example C is not mapped to any element. By definition for a function to be a function every element must be mapped to an unique element of the codomain{Note two elements of the domain can be mapped to the same element of the codomain) (ii) g is a function since every element of the domain A, B, Cis mapped to an element of the codomain 11,12,13. The domain is A, B, C, the codomain 11,12,13and the range 11,13. g is not onto since range 11,13 codomain 11,12,13. g is not one-to-one since two distinct elements of the domain have the same image, namely g ( B) 13, g (C ) 13 . Since neither g is not onto nor g is not one-to-one then by theorem g has no inverse. (Note if a function has not got one of these properties then it will not have an inverse.) (iii) h is a function since every element of the domain A, B, Cis mapped to an element of the codomain 11,12,13. The domain is A, B, C, the codomain 11,12,13and the range 11,12,13 . h is onto since range 11,12,13 codomain 11,12,13. h is one-to-one since no two distinct elements of the domain have the same image, namely h( A) 11, h( B) 13, h(C ) 12 . Since h is onto nor h is one-to-one then by theorem h has an inverse given by h 1 : 11,12,13 A, B, C where h 1 (11) A h 1 (13) B h 1 (12) C . 19