Now Solve Puz­zle Us­ing Lin­ear Al­ge­bra

This sev­enth ar­ti­cle in the math­e­mat­i­cal jour­ney through open source solves puzzles us­ing lin­ear al­ge­bra in Oc­tave.

OpenSource For You - - FOR U & ME -

Ma­trix maths is for­mally called lin­ear al­ge­bra. We have cov­ered its basics in an ear­lier ar­ti­cle. Now, let’s ap­ply what we learnt by solv­ing puzzles. Solv­ing ‘pur­chase puzzles’ Shrishti pur­chased 24 pen­cils and N2 erasers for ` 96. Divya pur­chased 2M pen­cils and N5 erasers for ` NMM. What are the prices of the pen­cil and the eraser?

As­sum­ing that ‘p’ is the price for pen­cils and ‘e’ is the price for erasers, we have the fol­low­ing two equa­tions: 24 * p + N2 * e = 96 2M * p + N5 * e = NMM Hence, we could get the val­ues of ‘ p’ and ‘ e’ by solv­ing th­ese equa­tions. Con­vert­ing them into lin­ear al­ge­bra form, they can be re- writ­ten us­ing ma­trix mul­ti­pli­ca­tion as fol­lows: 24 12 p 96 20 15 e = NMM which is Ax = b, ‘x’ be­ing the vec­tor with vari­ables ‘p’ and ‘e’. Hence, we need to find the value of ‘x’, which is

given by: x = A- Nb. Us­ing Oc­tave: $ oc­tave -qf oc­tave:1> A = [ > 24 12 > 20 15 > ]; oc­tave:2> b = [ > 96 > 100 > ]; oc­tave:3> x = inv(A) * b x= 2.0000 4.0000

oc­tave:4>

Hence, p = ` 2 and e = ` 4, i.e., each pen­cil costs ` 2 and an eraser costs ` 4. You may check by sub­sti­tut­ing th­ese

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.