Linear Algebra In the Mathematica examples below, boldface type is Input, regular type is Output.
A matrix will be displayed in this ``list of lists'' form unless you explicitly ask for it with MatrixForm. MatrixForm displays matrices in familiar rectangular form;
dm = DiagonalMatrix[ {2,3,5,7} ]
{{2, 0, 0, 0}, {0, 3, 0, 0}, {0, 0, 5, 0}, {0, 0, 0, 7}}
MatrixForm[dm]
MatrixForm= 2 0 0 0
0 3 0 0
0 0 5 0
0 0 0 7
Now let us define
vecA = {a,b,c,d}; vecB = {u,v,w,x};
Then matrix/vector multiplication is indicated
with `.':
dm . vecB
{2 u, 3 v, 5 w, 7 x}
dm . dm // MatrixForm
MatrixForm= 4 0 0 0
0 9 0 0
0 0 25 0
0 0 0 49
Inverse[dm] // MatrixForm
MatrixForm= 1
- 0 0 0
2
1
0 - 0 0
3
1
0 0 - 0
5
1
0 0 0 -
7
m = { {1,2,3}, {2,3,5}, {1,4,7} };
b = { 8, 16, 18 };
x = LinearSolve[ m, b ]
{3, -5, 5}
Other matrix functions include
Det,
Eigenvalues,
Eigenvectors.
Det[m]
-2
Eigenvalues[m] // N
-16 -16
{10.605 + 0. I, -0.279581 + 4.44089 10 I, 4543 - 4.44089 10 I}
Eigenvalues[m] // N // Chop
{10.605, -0.279581, 0.674543}
Eigenvectors[m] // N // Chop // MatrixForm
MatrixForm= 0.47526 0.782444 1.
0.820685 -2.02507 1.
-0.932309 -1.34829 1.
Graphics functions may be useful in visualizing matrices:
ListDensityPlot[ DiagonalMatrix[{2, 3, 0, 1.5, 1, 2.5, 2}] ];

Next:
Calculus
Table of Contents