Matrices -
introduction, presentation, transformations, determinats, reverse matrix, eigenvalues, solving systems of equations, etc. Using the File/Palettes/Basic Calculations/ List and Matrices menu

Example 1. Matrices in Mathematica are established in two ways - by standard multidimensional lists or through mathematical symbolics through a choice of palettes. Below is a list of the table a=3 x 5:

a = {{0, 2, 3, 1, 9}, {-2, 1, 0, 0, 3}, {12, 4, 0, -9, 2}}   (* This is a list *) MatrixForm[%]

{{0, 2, 3, 1, 9}, {-2, 1, 0, 0, 3}, {12, 4, 0, -9, 2}}

( 0    2    3    1    9  )            -2   1    0    0    3            12   4    0    -9   2

The next matrix b is established by choosing the symbol  (   )       from the palette of main symbols. Lines are added by placing the cursor on top of a given cell and pressing t CTRL and ENTER keys simultaniously. A column is added by simultaniously pressing CTRL and  , (comma).

b = (1   0   0   2   3)       1   2   0   3   5       3   8   3   1   6

{{1, 0, 0, 2, 3}, {1, 2, 0, 3, 5}, {3, 8, 3, 1, 6}}

Example 2. Operations on matrices are carried out according to the rules of the linar lagebra - addition, multiplication etc. Here is a sum and multiplication of a matrix with a number.

c = 5a ;  MatrixForm[%] d = 4a - 10b ;  MatrixForm[%]

( 0     10    15    5     45  )            -10   5     0     0     15            60    20    0     -45   10

( -10   8     12    -16   6   )            -18   -16   0     -30   -38            18    -64   -30   -46   -52

Example 3. Product of matrices is done with the symbol   .  (dot):

a1 = (2    0 ) ;        1    -2        9    1 b1 = (1    2    -2   0 ) ;        3    4    0    1 c1 = a1 . b1 ; MatrixForm[%]

( 2     4     -4    0   )            -5    -6    -2    -2            12    22    -18   1

Example 4.  Calculating  (p+q). (p-q). To compare results we have also calculated the intermediate results.

p = (1   2) ;       0   3 q = (0   2) ;       1   0 p + q ; MatrixForm[%] p - q ; MatrixForm[%] (p + q) . (p - q) ; MatrixForm[%]

( 1   4 )            1   3

( 1    0  )            -1   3

( -3   12 )            -2   9

Example 5. Determinants, transposition, increasing power, etc. Note that the operation a^3 performs the obtantation of a matrix each element raised in third power, while the operation a.a.a gives the triple product of the matrix a.

a = (2   3   0) ;       0   1   4       1   2   5 determinanta = Det[a] Transpose[a] ; MatrixForm[%] MatrixPower[a, 3] a . a . a a^3 MatrixForm[%]

6

( 2   0   1 )            3   1   2            0   4   5

{{20, 45, 96}, {32, 69, 156}, {47, 102, 225}}

{{20, 45, 96}, {32, 69, 156}, {47, 102, 225}}

{{8, 27, 0}, {0, 1, 64}, {1, 8, 125}}

( 8     27    0   )            0     1     64            1     8     125

Example 6. Matrix inversion and verifaction of the result through multiplication of  a  on the left and on the right by the resulting inverse matrix to obtain the identity matrix.

r=Inverse[a]
MatrixForm[%]
a.r
r.a

{{-1/2, -5/2, 2}, {2/3, 5/3, -4/3}, {-1/6, -1/6, 1/3}}

(  1    5      )           --   --            2    2   2            2    5     ...  -    --           3    3     3             1    1   1           --   --   -            6    6   3

{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

Example 7. Finding the rank of matrix with the method of elimination is done with the function  RowReduce.

a = (2    3    7 ) ;       2    3    7       12   3    7       4    3    7 RowReduce[a] ; MatrixForm[%]

(           )            1   0   0                    7                   -           0   1   3              0   0   0              0   0   0

Example 8. Calculation of eigenvalues and eigenvectors of square matrix can succeed, if it is possible to analythically solve of the characteristical equation. In the other cases a numerical method is used (see the corresponding interactive lessons).

b=.
b={{3,1},{4,0}}
Eigenvalues[b]
Eigenvectors[b]
c={{1,0,-3},{4,0,-2},{2,-2,3}}
Eigenvalues[c]
Eigenvectors[c]

{{3, 1}, {4, 0}}

{4, -1}

{{1, 1}, {-1, 4}}

{{1, 0, -3}, {4, 0, -2}, {2, -2, 3}}

{4,  5^(1/2), - 5^(1/2)}

{{-2, -3, 2}, {1/2 + ( 5^(1/2))/2, 2, 1}, {1/2 - ( 5^(1/2))/2, 2, 1}}

Example 9. Solving systems of linear equations with a n onsingular matrix  Ax=b. This is possible in two ways - by directly finding of the inverse matrix, x=A^(-1) b  , or by using the function LinearSolve[ ] .

A = (1       4       -4      0.4     1.6  ) ;       0.02    3.5     13      13.04   -44        ... cation of the accurace of the inverse matrix *) ; MatrixForm[%] x1 = r . b x2 = LinearSolve[A, b]

345305.

RowBox[{{, RowBox[{RowBox[{{, RowBox[{0.0279732, ,, 0.00504037, ,, 0.00460558, ,, RowBox[{-, 0 ... 0.0214666}], ,, RowBox[{-, 0.00892012}], ,, 0.00968367, ,, 0.0594927, ,, 0.000474677}], }}]}], }}]

( 0.9999999999999999`         -1.9081958235744878`*^-17   2.6020852139652106`*^-17     ... 3`*^-16    -5.4969050145015075`*^-17   -1.0408340855860843`*^-17   4.2500725161431774`*^-16    1.`

RowBox[{{, RowBox[{RowBox[{{, 0.151366, }}], ,, RowBox[{{, RowBox[{-, 0.582198}], }}], ,, RowBox[{{, RowBox[{-, 0.89788}], }}], ,, RowBox[{{, 0.866033, }}], ,, RowBox[{{, 0.149681, }}]}], }}]

RowBox[{{, RowBox[{RowBox[{{, 0.151366, }}], ,, RowBox[{{, RowBox[{-, 0.582198}], }}], ,, RowBox[{{, RowBox[{-, 0.89788}], }}], ,, RowBox[{{, 0.866033, }}], ,, RowBox[{{, 0.149681, }}]}], }}]


Created by Mathematica  (December 21, 2007)