Matrix operations

2 D interactive examples

A green vector p is interactively moved. The black vector is the result of matrix multiply  mat . p.

orig={0,0};
mat={{2,0},{0,2}};
MatrixForm[mat]

Manipulate[Graphics[{Green,Thick,Arrow[{orig,p}],Black,Arrow[{orig,mat.p}]},Axes->True,ImageSize->200,PlotRange->{{-4,4},{-4,4}},GridLines->Automatic],{{p,{2,0}},Locator}];

orig={0,0};
mat={{2,1},{1,2}};
MatrixForm[mat]

Manipulate[Graphics[{Green,Thick,Arrow[{orig,p}],Black,Arrow[{orig,mat.p}]},Axes->True,ImageSize->200,PlotRange->{{-4,4},{-4,4}},GridLines->Automatic],{{p,{2,0}},Locator}];

orig={0,0};
mat={{1,-1},{1,1}};
MatrixForm[mat]

Manipulate[Graphics[{Green,Thick,Arrow[{orig,p}],Black,Arrow[{orig,mat.p}]},Axes->True,ImageSize->200,PlotRange->{{-4,4},{-4,4}},GridLines->Automatic],{{p,{2,0}},Locator}];

orig={0,0};
mat={{1,1},{0,1}};
MatrixForm[mat]

Manipulate[Graphics[{Green,Thick,Arrow[{orig,p}],Black,Arrow[{orig,mat.p}]},Axes->True,ImageSize->200,PlotRange->{{-4,4},{-4,4}},GridLines->Automatic],{{p,{2,0}},Locator}];

orig={0,0};
mat={{1,1},{-0.5,1}};
MatrixForm[mat]

Manipulate[Graphics[{Green,Thick,Arrow[{orig,p}],Black,Arrow[{orig,mat.p}]},Axes->True,ImageSize->200,PlotRange->{{-4,4},{-4,4}},GridLines->Automatic],{{p,{2,0}},Locator}];

A  4D example

mat=Table[Abs[i-j],{i,1,4},{j,1,4}];
vec={1,1,1,1};

Print[MatrixForm[mat],".",MatrixForm[vec],"=",MatrixForm[mat.vec]];

Linearity

mat.(-2a + 3 )  =  mat.(-2)a + mat .3 b = -2mat.a + 3mat.b

mat=Table[Abs[i-j],{i,1,4},{j,1,4}];
a={1,1,1,1};
b={1,2,3,4};

Print[MatrixForm[mat.(-2a+3b)]];
Print[MatrixForm[-2mat.a+3*mat.b]];

A 3 D rotation

matalpha3={{Cos[alpha],Sin[alpha],0},{-Sin[alpha],Cos[alpha],0},{0,0,1}};
Print[MatrixForm[matalpha3]];

Manipulate[Graphics3D[{{Opacity[.35],Red,Cuboid[]},GeometricTransformation[{Opacity[.85],Red,Cuboid[]},RotationMatrix[alpha,{0,0,1}]]},Boxed->False,ImageSize->250,PlotRange->{{-1.5,1.5},{-1.5,1.5},{0,1}}],{alpha,0,2Pi}];

3 D scaling

Manipulate[Graphics3D[{{Opacity[.85],Red,Cuboid[]},GeometricTransformation[{Opacity[.35],Red,Cuboid[]},ScalingTransform[{s,s,s}]]},Boxed->False,ImageSize->250,PlotRange->{{0,3},{0,3},{0,3}}],{s,1,3}];

An uneven scaling.

Manipulate[Graphics3D[{{Opacity[.85],Red,Cuboid[]},GeometricTransformation[{Opacity[.35],Red,Cuboid[]},ScalingTransform[{r,s,t}]]},Boxed->False,ImageSize->250,PlotRange->{{0,3},{0,3},{0,3}}],{r,1,3},{s,1,3},{t,1,3}]