Solving simultaneous linear equations

The source code of a computer program written in Mouse that solves 3-equation 3-unknown problems is at

http://primepuzzle.com/mouse/SOLVE.MSE

A sample run of this program follows.

SOLVE.MSE (10/29/85)

a x  +  b y  +  c z   =   d
e x  +  f y  +  g z   =   h
i x  +  j y  +  k z   =   l

Cramer's Rule is used.  Please use small integers.

First run ?y

   a=2       b=4       c=0       d=39
   e=42      f=87      g=0       h=843
   i=0       j=0       k=1       l=1

         Enter Data !

SPACE means use old value (re-run) or 0 (first run).

x = 3 3/6
y = 8
z = 1

Press any key ...

NB: The above problem comes from a "word problem" a student of mine was
working on.

An electrician, a carpenter and a plumber are working on a job. It takes
them 21.5 hours to complete. The plumber works 2 more hours than the
carpenter. The electrician makes $21 / hour. The carpenter makes $19.50
/ hour. The plumber makes $24 / hour. Together, they made $469.50. How
long did the electrician work?

The plumber variable can be eliminated by setting p = c+2.

We get

  e +     c +   (c+2) = 21.5 (hours equation)
21e + 19.5c + 24(c+2) = 469.5 (money equation)

This can be solved by standard methods. By doubling the above two
equations (to get rid of the decimals) and by some simple rearrangements
we get

 2e +  4c =  39
42e + 87c = 843

Since the Mouse program is a 3-equation, 3-unknown solver, to use it we
created a third variable and set its value to 1.

Here's what my TI-nspire did w/ it. (Only the third use of linSolve is relevant.)



The inverse of the matrix

[a b]
[c d]

is

(ad-bc)-1 times

[ d -b]
[-c  a]

In the current case, the inverse is 

6-1 times

[ 87 -4]
[-42  2]

Note: ad-bc, the "determinant" of the matrix, must be non-zero for this inverse to exist.

6-1 times

[ 87 -4][ 39]
[-42  2][843]

equals

[21/6]
[48/6]

which equals

[3 3/6]
[8    ]

Note: for a somewhat related page, go to http://primepuzzle.com/tunxis/mary's-age.html