Who needs matrices?
If you can toss around matrices as you might a Frisbee, you're one of the superheroes. If not, you're on the sidelines, watching.
Now that we've completed the vector class, it's time to move on to the matrix (plural: matrices). In the worlds of math, engineering, and physics, it's the matrix that separates the men from the boys, the women from the girls, the heroes from the goats. If you can toss around matrices as you might a Frisbee, you're one of the superheroes. If not, you're on the sidelines, watching. Hint: if you say "matricee" as the singular of matrices, you're not even in the stadium.
I want to show you the C++ code that lets you toss around matrix-vector expressions, but at this point, I think it's much more important for me to give you the motivation.
• Why do I need a matrix?
• What good are they?
• How does matrix algebra help me?
John, Mary, et al.
Remember those word problems that used to drive you crazy in high school algebra? Here's an easy one, for old times' sake:
1. Between them, John and Mary have $1.00
2. John has three times as much money as Mary.
3. How much money does each child have?
Now, if you've been thinking outside the box, instead of having your eyes glaze over at the phrase "word problem," you already know the answer. Think three quarters in John's hand, one in Mary's.
Maybe that one was too easy. Try this one:
1. Between them, John, Mary, and Sue have $1.00.
2. Sue has 40 cents more than John.
3. Sue has as much money as John and Mary together.
Not so obvious this time, is it? As you may remember, the trick is to write down equations that capture the information in the problem. To keep it brief, let J, M, and S represent the money each child has. Fact #1 says:
The next one says:
Now we need to solve for the individual values. As you may remember, the trick is to manipulate the equations so that we isolate a single variable, one at a time. For example, Equation 2 gives us a value for S. Let's substitute it into the other two equations, to get:
A little simplifying gives:
Luckily, the terms in J in the last equation cancelled each other, isolating the value of M. We now know that Mary has 40 cents. Substituting that value into Equation 5 gives:
Now that we know the value of J, we can solve Equation 2 for S:
The problem is solved. John has 10 cents, Mary 40, and Sue, 50.
I should probably point out that the sequence of steps I used to solve the problem is not at all the only one, or even the best one.