Linear Math1

Meant to be read in conjunction the LinearMath1 video

Mathematica is happy to handle lists of components just as you would expect.
You can add them, multiply by overall scalar factors, or take Dot  and Cross products.

vec1={1,2,3}
vec2={1,0,-1}
vec1+2*vec2
Dot[vec1,vec2]
vec1.vec2
Cross[vec1,vec2]

Don’t confuse Dot and Cross with Times, the ordinary multiply with * as shorthand.

Times[vec1,vec2]
vec1*vec2

To display these vectors nicely on the page in a column, there is the function MatrixForm.
To make MatrixForm process every output before we see it, we can define the symbol $Post

MatrixForm[vec1]
$Post=MatrixForm
xhat={1,0}
yhat={0,1}

Of course a matrix is a list of lists, but note the row-vector convention.
And of course the Dot product gives the expected Matrix.vector result.
(Again be wary of accidentally using the *).

mat={{a,b},{c,d}}
mat.xhat
mat.yhat
mat*xhat (* oops why is this giving a matrix instead of a vector?! *)

Here is a visualizer which lets you choose which tilted pair of basis vectors to use as we display the action of the matrix.

mat={{2,1},{3,4}}   (*come back here and change this matrix as you explore *)
Manipulate[With[{r=RotationMatrix[θ],x={1,0},y={0,1},z={0,0}}, (* Create temporary symbols for xhat, yhat, and zero *)
Graphics[{
{Red,  {Dashed,Arrow[{z,r.x}]},Arrow[{z,mat.r.x}]},
{Blue,{Dashed,Arrow[{z,r.y}]},Arrow[{z,mat.r.y}]},
{Orange,Opacity[.4],Parallelogram[z,{mat.r.x,mat.r.y}]}
},PlotRange->6]],{θ,0,2π}]

Here is the Mathematica function Eigenvectors which somehow finds the eigenvectors of a given matrix

Eigenvectors[mat]

Next we define a pair of matrices and have Mathematica multiply them out using Dot (“.”), noting that order matters.

mat1={{a,b},{c,d}}
mat2={{e,f},{g,h}}
Dot[mat1,mat2]  (* this is the long version *)
mat1.mat2  (* this is the short version *)
mat2.mat1  (* note that order matters *)
mat1*mat2 (* and avoid this pitfall--- Times is not Dot! *)

And here is the function which finds the inverse matrix:

inv=Inverse[mat]
inv.mat
mat.inv

Here is the symbolic version, in which we see a determinant (Det) in every term.
BTW since det(A.B) = det(A)*det(B), for a matrix and its inverse we learn
Det[mat.inv]=Det[mat]*Det[inv]=Det[IdentityMatrix]=1

mat1
Inverse[mat1]
Det[mat1]
Det[Inverse[mat1]]//Simplify
mat1.mat2
Det[mat1.mat2]//Simplify

There are some special matrices which come as built in functions:

IdentityMatrix[11]
RotationMatrix[θ]

On homework you prove that:

MatrixForm[RotationMatrix[α]].MatrixForm[RotationMatrix[β]]==MatrixForm[RotationMatrix[α+β]]

Suppose that in the context of some collision problem you have a matrix Q=F.M and a vector describing the initial state:

m={{-15,32},{2,15}}/17
f={{-1,0},{0,1}}
q=f.m
state0={0,-1}

Then MatrixPower can be useful for applying the matrices large numbers of times:

MatrixPower[q,0,state0]
MatrixPower[q,1,state0]
MatrixPower[q,2,state0]
MatrixPower[q,6,state0]//N

BTW here is one line to plot out the successive states as red dots in the {v1,v2} plane.

ListPlot[Table[MatrixPower[q,n,state0],{n,0,6}],PlotStyle->{Large,Red}]