Matrix Arithmetic Manipulations
a={{a11, a12, a13, a14},{a21, a22, a23, a24},{a31, a32, a33, a34},
{a41, a42, a43, a44}}
MatrixForm[a] MatrixForm[b] MatrixForm[a+b]
The scalar multiple of a matrix and a real or complex number is defined by multiplying each entry by the number.
MatrixForm[a] MatrixForm[5 a]
The scalar product (or dot product or inner product ) of two row vectors (or two column vectors) is defined as the sum of aibi. In order to take the scalar product of two vectors, they must have the same size. Note also that the scalar product is a number, not a vector.
v={v1, v2, v3}
w={w1, w2, w3}
v.w
Matrix multiplication is defined in terms of the scalar product in a way that may seem unusual at first but in fact is quite natural, as we shall see later. If c is the matrix product of a and b, then cij is the scalar product of the ith row of a with the jth column of b.
c=a.b
MatrixForm[c]
Whew! Maybe smaller matrices would illustrate this better.
d={{d11, d12}, {d21, d22}}
e={{e11, e12}, {e21, e22}}
MatrixForm[d] MatrixForm[e] MatrixForm[d.e]
In order to multiply two matrices, they must be conformable, that is, the number of columns of the first matrix must equal the number of rows in the second matrix. How does this fit in with the scalar product and the definition of the matrix product???
m=Table[Random[],{4},{3}]
n=Table[10 Random[],{3},{5}]
MatrixForm[m] MatrixForm[n] MatrixForm[m.n]
x=Table[10 Random[],{2},{2}]
y=Table[10 Random[],{2},{4}]
MatrixForm[x] MatrixForm[y] MatrixForm[x.y]
z=Table[10 Random[],{5},{2}]
j=Table[10 Random[],{2},{3}]
MatrixForm[z] MatrixForm[j] MatrixForm[z.j]
MatrixForm[j.z]
Based on the above matrix multiplications, when you multiply and nxm matrix with an mxk matrix, what size matrix do you get? Try more of your own if you do not see the pattern.
The identity matrices are the matrix multiplication identity elements.
MatrixForm[z] MatrixForm[z.IdentityMatrix[2]]
MatrixForm[a.IdentityMatrix[4]]
An nxn square matrix P may have an inverse Q, that is, an nxn matrix such that PQ=QP=Identity Matrix of size n. If P has an inverse, P is called nonsingular or invertible. Otherwise P is called singular.
P={{1, 1, 4},{2, -2, 1},{0, 4, -1}}
Q={{-1/16, 17/32, 9/32},{1/16, -1/32, 7/32},{1/4, -1/8, -1/8}}
MatrixForm[P.Q] MatrixForm[Q.P]
Mathematica has a command to find the inverse of a (square) matrix.
b={{1, -1, 2}, {3, 2, 4}, {0, 1, -2}}
Inverse[b]
MatrixForm[Inverse[b]]
MatrixForm[b.Inverse[b]]
a={{1, -1, 1}, {2, 0, 1}, {3, -1, 2}}
Inverse[a]Mathematica has told us that a is singular and therefore has no inverse.
You can repeatedly multiply a matrix by itself (raise it to a power) using the MatrixPower command.
z={{1, 1, 0}, {0, 1, 0}, {0, 0, 1}}
MatrixPower[z, 4]