In the last post, we demonstrated the use of Cramer’s Rule as explained by Michael Kelley in Algebra Chapter 9. We saw that Cramer’s Rule works in J, but in this post and in a previous post using Matrix Divide in J, based on an APL method by Gary Helzer, we show there is a better way to solve these problems. Here is Problem 7 again in Kelley, Algebra, Chapter 9 pg 126. The original formula was:
6x -5y = -7
3x +2y = 1
The main difference from the Cramer Rule Method is that we take the numbers to the left of the equal sign and make a 2 by 2 matrix (A).
A =: 2 2 $ 6 _5 3 2
Then we take the numbers to the right of the equal sign and create a vector (B).
B =: _7 1
Then we use matrix divide (%.) to divide the vector (B) by a matrix (A) to get the values of x and y.
B %. A
(x,y = _0.33, 1)
(Note: Again, -1/3 is the answer Kelley shows in his work. The % command in J always produces a decimal answer. I rounded off the answer to -0.33. Also note that x,y are in the correct order.)
We arrive at the same result as shown in the answer key in Kelley’s Algebra, p. 286. This is a much simpler and more reliable method than Cramer’s rule in J or in the pencil and paper method. Once you have worked out a few sample problems and understand the pencil and paper methods, that should be sufficient for any placement tests. It’s unlikely that you would be asked to do complicated matrix algebra on pencil and paper exams, if only because of the time involved. I would not want to earn my living doing complex pencil and paper matrix algebra when J provides the computer programming tools for performing those calculations quickly and accurately.
Nonetheless, I want to be clear that I think Michael Kelley’s algebra books are much better than any pencil and paper math books I used in my schooling.
Next math post: Using J for Matrix Multiplication.