www.delorie.com/gnu/docs/calc/calc_52.html   search  
 
Buy the book!


GNU Emacs Calc 2.02 Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7.18 Matrix Tutorial Exercise 3

To solve trn(A) * A * X = trn(A) * B, first we compute A2 = trn(A) * A and B2 = trn(A) * B; now, we have a system A2 * X = B2 which we can solve using Calc's `/' command.

 
    a + 2b + 3c = 6
   4a + 5b + 6c = 2
   7a + 6b      = 3
   2a + 4b + 6c = 11

The first step is to enter the coefficient matrix. We'll store it in quick variable number 7 for later reference. Next, we compute the B2 vector.

 
1:  [ [ 1, 2, 3 ]             2:  [ [ 1, 4, 7, 2 ]     1:  [57, 84, 96]
      [ 4, 5, 6 ]                   [ 2, 5, 6, 4 ]         .
      [ 7, 6, 0 ]                   [ 3, 6, 0, 6 ] ]
      [ 2, 4, 6 ] ]           1:  [6, 2, 3, 11]
    .                             .

' [1 2 3; 4 5 6; 7 6 0; 2 4 6] RET  s 7  v t  [6 2 3 11]   *

Now we compute the matrix A2 and divide.

 
2:  [57, 84, 96]          1:  [-11.64, 14.08, -3.64]
1:  [ [ 70, 72, 39 ]          .
      [ 72, 81, 60 ]
      [ 39, 60, 81 ] ]
    .

    r 7 v t r 7 *             /

(The actual computed answer will be slightly inexact due to round-off error.)

Notice that the answers are similar to those for the 3x3 system solved in the text. That's because the fourth equation that was added to the system is almost identical to the first one multiplied by two. (If it were identical, we would have gotten the exact same answer since the 4x3 system would be equivalent to the original 3x3 system.)

Since the first and fourth equations aren't quite equivalent, they can't both be satisfied at once. Let's plug our answers back into the original system of equations to see how well they match.

 
2:  [-11.64, 14.08, -3.64]     1:  [5.6, 2., 3., 11.2]
1:  [ [ 1, 2, 3 ]                  .
      [ 4, 5, 6 ]
      [ 7, 6, 0 ]
      [ 2, 4, 6 ] ]
    .

    r 7                            TAB *

This is reasonably close to our original B vector, [6, 2, 3, 11].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003