MGM.04 SVD Analysis of 2D Matrices
 LITERACY

Needs["LinearAlgebra`MatrixManipulation`"];
Needs["Graphics`Colors`"];
Off[General::"spell"];
Off[General::"spell1"];
Off[ParametricPlot3D::"ppcom"];
Off[ParametricPlot::"ppcom"];
Off[Plot::"plnr"];
SetOptions[Limit, Analytic -> True];
$Pre = Chop;

CMView = {2.7, 1.6, 1.2};

Vector Drawer

\(\(\( (*\ \(\(:\)\(Date : \ \ Copyright\ 2001\)\), \ 
      Math\ Everywhere, \ \(\(Inc\)\(.\)\)\ 
*) \)\(
\)\( (*
Original\ Conception\ to\ create\ a\ vector\ drawer\ is\ due\ to\ Bill\ Davis . 
Current\ code\ is\ by\ Bruce\ \(\(Carpenter\)\(.\)\)
*) \)\(
\)\( (*\ \ \(\(\(:\)\(Drawbacks : \ \ Since\ the\ vectors\ are\ drawn\ out\ of\)\)\ 

      \ \ \ \ \ context\), \ 
      the\ shapes\ of\ the\ arrowheads\ are\ only\ 
\ \ \ \ \ correct\ with\ AspectRatio\ set\ to\ \(\(Automatic\)\(.\)\)
*) \)\)\)

BeginPackage["Vector3D`","Graphics`Colors`"];

Axes3D::usage = "Axes3D[a, b] creates a Graphics3D object of cartesian axes with x, y, and z running from -a/3 to a, and with axes labels b units beyond the tips of the axes.  Axes3D[a] is Axes3D[a, a/8].";

Perpend::usage = "Perpend[a] returns a unit vector which is perpendicular to the vector a.";

Arrow::usage = "Arrow[a] produces a 2 or 3 dimensional vector from the origin to a. Arrow[a, Tail -> tail] gives a vector from tail to a.";
	
Vector::usage = "Vector[a, b] gives a 2D or 3D vector from a to b.";

ArrowHead::usage = "ArrowHead[a, vec] produces an arrowhead with its tip placed at the point a, pointing in the direction of the vector vec.";

Tail::usage = "Tail -> point puts the tail of the vector at point.";

Norm::usage = "Norm[vec] returns the Euclidean length of vec.";

Normalize::usage = "Normalize[vec] returns a unit vector in the direction of vec, provided vec is nonzero.";

Aperture::usage = "Aperture is the ratio of the radius of the base to the length of the head of a vector.";

TipSize::usage = "TipSize specifies an absolute size for the inner tip length of the head of a vector.";

TipRatio::usage = "TipRatio is the ratio of the inner length of the arrowhead to the length of the shaft of a vector.";

HeadRatio::usage = "HeadRatio is the ratio of the outer length of the arrowhead to the length of the shaft of a vector.";

HeadSize::usage = "HeadSize specifies an absolute size for the head of a vector.";

ScaleFactor::usage = "ScaleFactor specifies the amount to scale a vector in length and may be either a number or a pure function.";

ZeroVectorPointSize::usage = "ZeroVectorPointSize is the size of the point used to represent a zero vector.";

Options[Vector] = Options[Arrow] = Options[ArrowHead] =
{HeadRatio -> 0.18, TipRatio -> 0.14, Aperture -> 0.3, ScaleFactor -> 1, HeadType -> Polygon, ShaftQ -> True, EdgesQ -> True, VectorColor -> RGBColor[0,0,1], ShaftWidth -> 0.005, ZeroVectorPointSize -> 0.01};
		
Begin["`Private`"];

SetOptions[ParametricPlot,AspectRatio -> Automatic];
SetOptions[Plot,AspectRatio -> Automatic];
SetOptions[Graphics,AspectRatio -> Automatic];

Axes3D[u_,v_] := 
      Graphics3D[{
            {Blue,Line[{{-u/3,0,0},{u,0,0}}]},
                    Text["x",{u + v,0,0}],
            {Blue,Line[{{0,-u/3,0},{0,u,0}}]},
                    Text["y",{0, u + v,0}],
            {Blue,Line[{{0,0,-u/3},{0,0,u}}]},
                    Text["z",{0,0,u + v}]}]; 
Axes3D[u_] := Axes3D[u,u/8];
				
Norm[a_?VectorQ] := N[Sqrt[a.a]];

Normalize[a_?VectorQ] := If[a.a == 0, a, a/Norm[a]];

Perpend[a_?VectorQ] := Normalize[{a[[2]],-a[[1]]}]/;Length[a]==2;

Perpend[a_?VectorQ]:=
    Normalize[If[a[[1]]==0,{1,0,0},{a[[2]],-a[[1]],0}]]/;
      Length[a]==3;
      
Base3D = Table[{Cos[2 k Pi/8.], Sin[2 k Pi/8.]},{k,0,8}]; 

Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, sw, ht, hs, hr, tr, ap, sf, vc, zvps, diff = to - from, tip},
   {sq, sw, ht, hs, hr, ts, tr, ap, sf, vc, zvps} = {ShaftQ, ShaftWidth, HeadType, HeadSize, HeadRatio, TipSize, TipRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]; tr = 0.75 hr];
   If[NumberQ[ts], tr = ts/Norm[diff]];
   Graphics[{If[sq,{vc,Thickness[sw],Line[{from,tip - tr diff}]},{}],
      With[{trans = ap hr Norm[diff] Perpend[diff]},
      {vc, Thickness[sw], ht[{tip,
                   (tip - hr diff + trans),
                   (tip - tr diff),
                   (tip - hr diff - trans),tip}]}]}]
] /; Length[from]==Length[to]==2

Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, eq, sw, hs, hr, tr,ap, sf, vc, zvps, diff = to - from, tip},
   {sq, eq, sw, hs, hr, ap, sf, vc, zvps} = {ShaftQ, EdgesQ, ShaftWidth, HeadSize, HeadRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics3D[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]];
   tr = hr/2;
   Graphics3D[{If[sq,{vc,Thickness[sw],Line[{from,tip-tr diff}]},{}], If[eq, {}, EdgeForm[]], {SurfaceColor[vc],
      With[{temp = Perpend[diff]},
      Polygon[Append[#,tip]]& /@ Partition[(tip - hr diff + #)&/@((ap hr Norm[diff] Base3D) . {temp,Normalize[Cross[temp,diff]]}),2,1]]}}]
] /; Length[from]==Length[to]==3


Arrow[a_, Tail->b_, opts___] := Vector[b,a+b,opts]

Arrow[a_, opts___] := Vector[Table[0,{Length[a]}],a,opts]

ArrowHead[a_, b_, opts___] := Vector[a-b,a,ShaftQ->False,opts];

End[];

EndPackage[];
Null

Graphics`Colors`GosiaGreen = 
        RGBColor[0,  0.392187,  0];

ThreeAxes[u,v]

ThreeAxes[u_, v_] := 
        Graphics3D[{{Blue, Line[{{-u, 0, 0}, {u, 0, 0}}]}, 
            Text["x", {u + v, 0, 0}], {Blue, 
              Line[{{0, -u, 0}, {0, u, 0}}]}, 
            Text["y", {0, u + v, 0}], {Blue, 
              Line[{{0, 0, 0}, {0, 0, u}}]}, 
            Text["z", {0, 0, u + v}]}];
ThreeAxes[u_] := ThreeAxes[u, (u/8)];
ThreeAxes::"usage" = "ThreeAxes[a,b] makes a standard cartesian \
axis graphics object with x, y, and z running from -a to a, and with axis \
labels b units beyond the tips of the axes.  ThreeAxes[a] is \
ThreeAxes[a,a/8].";

What you should be able to handle when you are away from the machine.

L.1)

Explain this:
Given a 2D matrix A, if you can come up with an s (in radians) so that
   A . {Cos[s], Sin[s]} is perpendicular to A . {Cos[s + (π/2)], Sin[s + (π/2)]}, then you can read off 
   1) SVD aligner for A
   2) SVD stretchfactors for A
   3) SVD hanger for A

My choice is 1).

L.2)

Here's a random 2D matrix A:

\(\(A\  = \ {{Random[Real, {2, 3}], 
            Random[Real, {0.5, 1.5}]}, 
\ \ \ \ \ \ \ \ \ \ \ \ \ {Random[
              Real, {1, 1.5}], Random[Real, {\(-2\), \(-1\)}]}};\)\)
MatrixForm[A]

Here's the ellipse you get when you hit this matrix on the unit circle centered at {0,0}:

ranger  = 1.1 Max[SingularValues[A][[2]]]; 
Clear[t];
ellipseplot  =  
        ParametricPlot[A . {Cos[t], Sin[t]}, {t, 0, 2 Pi}, 
          PlotStyle -> {{Thickness[0.01], Blue}}, 
          AxesLabel -> {"x", "y"}, 
          PlotRange -> {{-ranger, ranger}, {-ranger, 
                ranger}}];

The SVD hanger matrix for A is:

hanger = 
        Transpose[SingularValues[
              A][[1]]];
MatrixForm[hanger]

The SVD stretcher matrix for A is:

stretcher = 
        DiagonalMatrix[SingularValues[
              A][[2]]];
MatrixForm[stretcher]

The SVD aligner matrix for A is:

aligner = SingularValues[
            A][[3]];
MatrixForm[aligner]

Fill the blanks:
The length of the long axis of this ellipse is 2 * 3.05778
The length of the short axis of this ellipse is 2 * 1.9065
The perpendicular frame {perpframe[1],perpframe[2]} that defines the long and the short axes of this ellipse is 
              perpframe[1] = {-0.899195, -0.437548}
              perpframe[2] = {-0.437548, 0.899195} (the two columns of the SVD hanger matrix for A)
The area enclosed by this ellipse is (3.05778) times (1.9065)  times π.

L.3)

Given a 2D matrix A how do you use the SVD stretch factors of A to determine whether A is invertible?

Here's a random 2D matrix A:

A = (({{Random[Real, {-4, 4}], Random[Real, {-4, 4}]}, {Random[Real, {-4, 4}], Random[Real, {-4, 4}]}}));
MatrixForm[
      A]

We are going to use SVD analysis to determine whether this matrix is invertible.

We first check the SVD stretch factors:

{xstretch, ystretch}=SingularValues[A][[2]]

Neither stretch factor is 0.
This tells you that is matrix is invertible.

L.4)

Given a 2D matrix A how do you use the SVD stretch factors of A to determine the rank of A?

Here is the matrix
         A=(({{-0.7, 1.4}, {0.5, -1.0}})) 
and an SVD analysis of its stretch factors:

A=(({{-0.7, 1.4}, {0.5, -1.0}}));
MatrixForm[
      A]

stretches=SingularValues[A][[2]]

B=(({{-0.3, 1.4}, {0.5, 0.2}}));
MatrixForm[
      A]
Null

stretches=SingularValues[B][[2]]

The rank of a matrix is the number of dimensions the matrix uses to hang its hits. If a matrix hangs all its hits on a one dimensional 
straight line then we say that the rank of this matrix is 1. On the other hand, invertible 2D matrices use all of 2D to hang their hits. That's why 
we say that the rank of an invertible 2D matrix is 2. Look above at the two examples. In the first case where mathematica reports only one
stretch factor, we have a matrix with rank 1 and in the second example where neither stretch factor is 0 we have a matrix with rank 2.

L.5)

Lots of folks like to say that a given 2D matrix A is:
-> invertible if Det[A] ≠ 0
-> not invertible if Det[A] = 0.
Explain why they are right.

We know that |Det[A]|  = xstretch ystretch and from L.3) we saw that if neither stretch factor is 0 then a matrix is invertible. These
bits of information tell us that a given 2D matrix A is invertible if Det[A] = xstretch ystretch ≠ 0 (neither stretch factor is 0) or
not invertible if Det[A] = xstretch ystretch = 0 (at least one stretch factor is 0).

L.6)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{a, 0}, {0, b}})).aligner.
with a and b both positive. 
This information tells you that given any 2D vector Y, there is exactly one 2D vector X with A.X = Y.
Agree ∴ Det[A] = xstretch ystretch ≠ 0 (neither stretch factor is 0 because a and b are both positive), matrix A is invertible, so X = (A^(-1))Y.
Disagree........................................

L.7)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{a, 0}, {0, 0}})).aligner.
with a > 0. 
This information tells you that the rank of A is 1.
Det[A] = xstretch ystretch = 0 (ystretch is 0 where a  > 0), the matrix A is not invertible and its rank is 1.

L.8)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{a, 0}, {0, 0}})).aligner.
with a >0. 
This information tells you that if a 2D vector Y is on a certain line through {0,0}, then there is exactly one 2D vector X with A.X = Y.
Agree........................................
Disagree ∴ Det[A] = xstretch ystretch = 0 (ystretch is 0 where a  > 0), the matrix A is not invertible, so there is not exactly one 2D
vector X with A.X = Y.

L.9)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{1.234, 0}, {0, 0.0}})).aligner.
This information tells you that given a 2D vector Y, then  either
A.X = Y has no solution X or A.X = Y has many solutions X.
Agree ∴ 
Disagree........................................

L.10)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{3.0, 0}, {0, 2.0}})).aligner.
You plot the SVD aligner frame and learn it is a right hand perpendicular frame.
You plot the SVD hanger frame and learn it is a right hand perpendicular frame.
Fill the blank:
Det[A] =6

L.11)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{2.0, 0}, {0, 5.0}})).aligner.
You plot the SVD aligner frame and learn it is a left hand perpendicular frame.
You plot the SVD hanger frame and learn it is a left hand perpendicular frame.
Fill the blank:
Det[A] = 10

L.12)

You are given a 2D matrix A and learn that  Det[A] < 0. This tells you that a hit with A incorporates a flip.
Agree ∴ Disagree........

L.13)

You are given a 2D matrix A and learn that  Det[A] > 0. This tells you that  a hit with A incorporates no flip.
Agree ∴  Disagree........

L.14)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{4.0, 0}, {0, 0.5}})).aligner.
You plot the SVD aligner frame and learn it is a right hand perpendicular frame.
You plot the SVD hanger frame and learn it is a left hand perpendicular frame.
Fill the blank:
Det[A] = -20

L.15)

Given a 2D matrix A you do an SVD analysis and get
            A = hanger.(({{3.0, 0}, {0, 2.0}})).aligner.
You plot the aligner frame and learn it is a left hand perpendicular frame.
You plot the hanger frame and learn it is a right hand perpendicular frame.
Fill the blank:
Det[A] = -6

L.16)

Given a 2D matrix A you do an SVD analysis and get
             A =  hanger.(({{a, 0}, {0, b}})). aligner.
Using this, you can compute (A^(t ))via the formula:

a)  (A^t) =  aligner.(({{b, 0}, {0, a}})). hanger             b)  (A^t) =  (hanger^t).(({{b, 0}, {0, a}})). (aligner^t)

c)  (A^t) =  (aligner^t).(({{a, 0}, {0, b}})). (hanger^t)         d)  (A^t) =  (aligner^t).(({{b, 0}, {0, a}})). (hanger^t)

My choice is c

L.17)

Given a 2D matrix A you do an SVD analysis and get
             A =  hanger.(({{a, 0}, {0, b}})). aligner.
The aligner frame for A serves as a hanger frame for (A^t) and the hanger frame for A serves as an aligner frame for (A^t).
Agree ∴  Disagree.........

L.18)

Given a 2D matrix A, explain why
		Det[(A^t)] = Det[A]. 
Because
if we go with any 2D matrix 
        A = hanger.stretcher.aligner.
This gives
        (A^t) = (aligner^t).stretcher.(hanger^t).
This tells you why A and   (A^t)  have the same stretch factors
So 
         Det[A] = Det[hanger] Det[stretcher] Det[aligner] 
and
        Det[(A^t)] = Det[(aligner^t)] Det[stretcher] Det[(hanger^t)].
But  Det[(aligner^t)] = Det[aligner] and Det[hanger] = Det[(hanger^t)]
Reasons: If the aligner frame is a right hand frame, then  (aligner^t) is a hanger based on the same right hand frame. 
So Det[aligner] = Det[  (aligner^t)] = 1.
If the aligner frame is a left hand frame, then  (aligner^t) is a hanger based on the same left hand frame.
So Det[aligner] = Det[  (aligner^t)] = -1.
If the hanger frame is a right hand frame, then  (hanger^t) is a aligner based on the same right hand frame. 
So Det[hanger] = Det[  (hanger^t)] = 1.
If the hanger frame is a left hand frame, then  (hanger^t) is a aligner based on the same left hand frame.
So Det[hanger] = Det[(hanger^t)] = -1.
The upshot: Det[A] and  Det[(A^t)] are both the product of the same three numbers. 
This makes them equal.

L.19)

Given an invertible 2D matrix A you do an SVD analysis and get
             A =  hanger.(({{a, 0}, {0, b}})). aligner.
Using this, you can compute (A^(-1 ))via the formula:

a)  (A^(-1)) =  aligner.(({{(1/a), 0}, {0, (1/b)}})). hanger       b)  (A^(-1)) =  (hanger^t).(({{(1/a), 0}, {0, (1/b)}})). (aligner^t)
 
c)  (A^(-1)) =  (aligner^t).(({{(1/a), 0}, {0, (1/b)}})). (hanger^t)    d)  (A^(-1)) =  (aligner^t).(({{(1/b), 0}, {0, (1/a)}})). (hanger^t)

My choice is  c

L.20)

Given an invertible 2D matrix A you do an SVD analysis and get
             A =  hanger.(({{a, 0}, {0, b}})). aligner.
The aligner frame for A serves as a hanger frame for (A^(-1)) and the hanger frame for A serves as an aligner frame for (A^(-1)).
Agree ∴  Disagree..........

L.21)

Given a 2D invertible matrix A, explain why
		Det[(A^(-1))] = (1/Det) [A]. 
Because
		Identity =  (A^(-1)). A
So
        1  = Det[Identity] = Det[(A^(-1))] Det[A].
And so
        (1/Det) [A] = Det[(A^(-1))] .

L.22)

You are given a 2D matrix A and after you do your SVD analysis of it, you learn that both xstretch and ystretch are positive.
You make the call: 
Can there be an {x,y} with 
      {x,y} ≠ {0,0}
and with 
        A.{x,y} = {0,0}? 
 Look the plot below:

A=(({{Random[Real, {-2, 2}], Random[
                      Real, {-2, 2}]}, {Random[Real, {-2, 2}], Random[
                      Real, {-2, 2}]}}));
{xstretch, ystretch}=SingularValues[A][[2]];
MatrixForm[
        A];
{x, y} = {Random[Real, {-3, 3}], 
          Random[Real, {-3, 3}]};
xynorm = (Sqrt[{x, y} . {x, y}]);

ellipseplot  =  
          ParametricPlot[
            A . {xynorm Cos[t], xynorm Sin[t]}, {t, 0, 2 π}, 
            PlotStyle -> {{Red, Thickness[0.01]}}, 
            DisplayFunction -> Identity];

hitxyplot = 
        Graphics[{CadmiumOrange, PointSize[0.03], 
            Point[A . {x, y}]}];
hitxylabel = Graphics[{Black, Text["\!\(\*
StyleBox[\"A\",\nFontSize->14]\)\!\(\*
StyleBox[\".\",\nFontSize->14]\)\!\(\*
StyleBox[\"{\",\nFontSize->14]\)\!\(\*
StyleBox[\"x\",\nFontSize->14]\)\!\(\*
StyleBox[\",\",\nFontSize->14]\)\!\(\*
StyleBox[\"y\",\nFontSize->14]\)\!\(\*
StyleBox[\"}\",\nFontSize->14]\)", A . {x, y}, {-1, -1.5}]}];

littlecircleplot=Graphics[{GosiaGreen,Thickness[0.01],Circle[{0, 0},xynorm Min[{xstretch, ystretch}]]}];
bigcircleplot=Graphics[{Indigo,Thickness[0.01],Circle[{0, 0},xynorm Max[{xstretch, ystretch}]]}];

Show[hitxyplot, hitxylabel, littlecircleplot, 
        ellipseplot , bigcircleplot, PlotRange -> All, Axes -> True, 
        AxesLabel -> {"x", "y"}];

This plot shows:
▪  A.{x,y} for a random point {x,y} and a random 2D matrix A.
▪ The circle of 
         radius = ||{x,y}|| Min[{xstretch,ystretch}] 
centered at {0,0}.
▪ The circle of 
         radius =||{x,y}|| Max[{xstretch,ystretch}] 
centered at {0,0}.
▪ The the ellipse you get when you hit A on the circle centered at {0,0} that runs through {x,y}.
We observe that a hit with A cannot squash a non-zero vector onto the zero vector. In other words,
the hit by A cannot force the ellipse onto the zero vector, because the point {x,y} will never cross inside the smaller circle.

L.23)

You are given a 2D matrix A and after you do your SVD analysis of it, you learn that both xstretch is positive and ystretch = 0.
You make the call: 
Can there be an {x,y} with 
      {x,y} ≠ {0,0}
and with 
        A.{x,y} = {0,0}? 
YES, matrix A in not invertible, ystretch = 0.

L.24)

Here's a  2D matrix A:

\(\(A\  = \ {{0.5\ Random[Integer, {2, 5}], 
            0.5\ Random[
                Integer, {2, 5}]}, \ \ \ 
		\ \ \ \ \ \ \ {0.5\ Random[
                Integer, {2, 5}], \(-0.5\)\ Random[
                Integer, {2, 5}]}};\)\)
MatrixForm[A]

Here is the square with corners at {-1,-1}, {1,-1},{1,1}, and {-1,1}:

ranger = Max[{1.2, Norm[A . {1, 0}] + Norm[A . {0, 1}]}];
Show[
        Graphics[{Thickness[0.01], Blue, 
            Line[{{-1, -1}, {1, -1}, {1, 1}, {-1, 
                  1}, {-1, -1}}]}], 
        PlotRange -> {{-ranger, ranger}, {-ranger, ranger}}, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Before"];

Here's what you get when you hit this square with A:

\(\(Show[
        Graphics[{Thickness[0.01], Red, 
            Line[{A . {\(-1\), \(-1\)}, A . {1, \(-1\)}, A . {1, 1}, 
                A . {\(-1\), 1}, 
                A . {\(-1\), \(-1\)}}]}], 
\ \ \ \ \ PlotRange -> {{\(-ranger\), ranger}, {\(-ranger\), ranger}}, 
\ \ \ \ \ Axes -> True, 
        AxesLabel -> {"x", "y"}, 
        PlotLabel -> "After"];\)\)

The determinant of A is:

Det[A]

The area enclosed by the parallelogram is area = —Det[A] = 7. The columns of A are negatively oriented.

L.25)

Here are two vectors X and Y and their plot:

X  =  {0.2 Random[Integer, {4, 10}], 
        0.2  Random[Integer, {4, 10}]}
X;
Y  =  {-0.5 Random[Integer, {2, 5}], 
        0.5 Random[Integer, {2, 5}]}
Y;
\(\(vectorplot\  = \ 
        Show[Arrow[X, Tail -> {0, 0}, 
            VectorColor -> Blue], 
		\ \ \ \ \ \ \ Arrow[Y, 
            Tail -> {0, 0}, VectorColor -> Blue], 
	
          Graphics[{Red, Text["X", X/2]}], 	
          Graphics[{Red, Text["Y", Y/2]}], 
	Axes -> True, 
          AxesLabel -> {"X", "Y"}, PlotRange -> All];\)\)

Here is the parallelogram these two vectors define:

\(\(Show[
        vectorplot, 
	\ \ \ Graphics[
          Line[{{0, 0}, X, X + \ Y, Y, {0, 0}}]]];\)\)

Tell how you would use X and Y to set up a matrix A so that |Det[A]| calculates the  area of this parallelogram.
              A = 
The X and Y are the two columns of matrix A.

L.26)

Here's a 2D matrix A:

A  =  {{0.7, 1.8}, {-0.8, 0}};
MatrixForm[A]

Here are (A^t), the transpose of A, and (A^(-1)), the inverse of A:

MatrixForm[Transpose[A]]
MatrixForm[Inverse[A]]

They don't look much alike. 
But see what they do when you hit both on the unit circle:

Clear[x, y, t, s];
{tlow, thigh} = {0, 2 π};
{x[t_], y[t_]} = {Cos[t], Sin[t]};
Clear[hitplotter, hitpointplotter, pointcolor, actionarrows, 
        matrix2D];
hitplotter[matrix2D_] := 
      ParametricPlot[matrix2D . {x[t], y[t]}, {t, tlow, thigh}, 
        PlotStyle -> {{Thickness[0.02], Blue}}, 
        AxesLabel -> {"x", "y"}, 
        DisplayFunction -> Identity]; 
    Show[hitplotter[Transpose[A]], hitplotter[Inverse[A]], 
      PlotLabel -> "Hits with Transpose[A] and Inverse[A]", 
      DisplayFunction -> $DisplayFunction];

Describe what you see and try to explain why you see it.
A hit with (A^t) has the inverse rotation of the hit with (A^(-1 )), and it has the inverse affect on stretching (shrinks rather than expands). 
This is caused by the special way we swap rows for the transposition.
Some questions to ponder:
Both ellipses seem to be hanging on the same perpendicular frame. What perpendicular frame is it?
Perfoming a SVD analysis to matrix A we get:

A={{0.7,-0.8},{1.8,0}};
MatrixForm[A]

aligner=SingularValues[A][[3]];
MatrixForm[
      aligner]

hanger=Transpose[SingularValues[A][[1]]];
MatrixForm[
      hanger]

stretcher=DiagonalMatrix[SingularValues[A][[2]]];
MatrixForm[
      stretcher]

The two columns of the aligner frame above form the base of perpendicular frame.
Why does the long axis of each ellipse line up with the short axis of the other?
Remember that holds:
The aligner frame for A serves as a hanger frame for (A^t) and the hanger frame for A serves as an aligner frame for (A^t).
The aligner frame for A serves as a hanger frame for (A^(-1)) and the hanger frame for A serves as an aligner frame for (A^(-1)).
When you multiply the area enclosed by one of the ellipses times the area enclosed by other ellipse, what do you get? 
We get (π^2).

L.27)

Here's a random matrix A:

Clear[alignerframe];
s  =  Random[Real, {-Pi/2, Pi/2}];
\(\({alignerframe[1], 
          alignerframe[
            2]}\  = \ 
\ \ \ \ \ \ \ \ \ \ \ N[{{Cos[s], 
              Sin[s]}, {Cos[s\  + \ Pi/2], Sin[s\  + \ Pi/2]}}];\)\)
\(\(\(aligner\  = \ {alignerframe[1], alignerframe[2]};\)\(
\)
    \)\)
{xstretch, ystretch}  =  {0.4 Random[Integer, {3, 5}], 
          0.3 Random[Integer, {1, 3}]};
\(\(\(stretcher\  = \ {{xstretch, 0}, {0, ystretch}};\)\(
\)
    \)\)
Clear[hangerframe];
s  =  Random[Real, {-Pi/2, Pi/2}];;
\(\({hangerframe[1], 
          hangerframe[
            2]}\  = \ 
\ \ \ \ \ \ \ \ \ \ \ N[{{Cos[s], 
              Sin[s]}, {Cos[s\  + \ Pi/2], Sin[s\  + \ Pi/2]}}];\)\)
hanger  =  Transpose[{hangerframe[1], hangerframe[2]}];
A  =  hanger . stretcher . aligner;
MatrixForm[A]

Here is the square with corners at {-1,-1}, {1,-1},{1,1}, and {-1,1}:

Show[
        Graphics[{Thickness[0.01], Blue, 
            Line[{{-1, -1}, {1, -1}, {1, 1}, {-1, 
                  1}, {-1, -1}}]}], PlotRange -> All, 
        Axes -> True, AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Before"];

Here are the parallelograms you get what you get when you hit this square with this matrix and its transpose:

Ahit  =  
        Graphics[{Thickness[0.01], Red, 
            Line[{A . {-1, -1}, A . {1, -1}, A . {1, 1}, 
                A . {-1, 1}, A . {-1, -1}}]}];
B  =  Transpose[A];
\(\(\(transAhit\  = \ \ Graphics[{Thickness[0.01], Blue, 
            Line[{B . {\(-1\), \(-1\)}, B . {1, \(-1\)}, B . {1, 1}, 
                B . {\(-1\), 1}, B . {\(-1\), \(-1\)}}]}];\)\(
\)
    \)\)
\(\(Show[Ahit, transAhit, PlotRange -> All, 
\ 
\ \ \ \ \ Axes -> True, 
        AxesLabel -> {"x", "y"}];\)\)

Express the measurement of area enclosed by one of these parallelograms in terms of the measurement of the area enclosed by the other.
The two areas are equal.  Remember :          A =  hanger.(({{xstretch, 0}, {0, ystretch}})). aligner     and   (A^t) =  (aligner^t).(({{xstretch, 0}, {0, ystretch}})). (hanger^t).
Area = determinant of each matrix =  xstretch * ystretch for both cases.

L.28)

Here's a random matrix A:

Clear[alignerframe];
s  =  Random[Real, {-Pi/2, Pi/2}];
\(\({alignerframe[1], 
          alignerframe[
            2]}\  = \ 
\ \ \ \ \ \ \ \ \ \ \ N[{{Cos[s], 
              Sin[s]}, {Cos[s\  + \ Pi/2], Sin[s\  + \ Pi/2]}}];\)\)
\(\(\(aligner\  = \ {alignerframe[1], alignerframe[2]};\)\(
\)
    \)\)
{xstretch, ystretch}  =  {0.4 Random[Integer, {3, 5}], 
          0.3 Random[Integer, {1, 3}]};
\(\(\(stretcher\  = \ {{xstretch, 0}, {0, ystretch}};\)\(
\)
    \)\)
Clear[hangerframe];
s  =  Random[Real, {-Pi/2, Pi/2}];
\(\({hangerframe[1], 
          hangerframe[
            2]}\  = \ 
\ \ \ \ \ \ \ \ \ \ \ N[{{Cos[s], 
              Sin[s]}, {Cos[s\  + \ Pi/2], Sin[s\  + \ Pi/2]}}];\)\)
hanger  =  Transpose[{hangerframe[1], hangerframe[2]}];
A  =  hanger . stretcher . aligner;
MatrixForm[A]

Here is the square with corners at {0,0},{1,0},{1,1}, and{0,1}:

Show[
        Graphics[{Thickness[0.01], Blue, 
            Line[{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}]}], 
        PlotRange -> All, Axes -> True, 
        AxesLabel -> {"x", "y"}, 
        PlotLabel -> "Before"];

Here are the parallelograms you get what you get when you hit this square with this matrix and its inverse:

Ahit  =  
        Graphics[{Thickness[0.01], Red, 
            Line[{A . {0, 0}, A . {1, 0}, A . {1, 1}, A . {0, 1}, 
                A . {0, 0}}]}];
B  =  Inverse[A];
\(\(\(invAhit\  = \ 
        Graphics[{Thickness[0.01], Blue, 
            Line[{B . {0, 0}, B . {1, 0}, B . {1, 1}, B . {0, 1}, 
                B . {0, 0}}]}];\)\(
\)
    \)\)
\(\(Show[Ahit, invAhit, PlotRange -> All, 
\ Axes -> True, 
        AxesLabel -> {"x", "y"}];\)\)

Express the measurement of area enclosed by one of these parallelograms in terms of the measurement of the area enclosed by the other.
Remember that    A =  hanger.(({{xstretch, 0}, {0, ystretch}})). aligner and (A^(-1)) =  (aligner^t).(({{(1/xstretch), 0}, {0, (1/ystretch)}})). (hanger^t). 
Area = determinant of each matrix =  xstretch * ystretch for the first case and 1/(xstretch * ystretch) for the second case. From this we get
area enclosed by one of these parallelograms = 1/(area enclosed by the other).

Hand Calculation Literacy

LHC.1) Determinants

Here's a random 2D matrix:

A = {{Random[Integer, {-3, 3}], 
            Random[Integer, {-3, 3}]}, {Random[Integer, {-3, 3}], 
            Random[Integer, {-3, 3}]}};
MatrixForm[A]

Give a hand calculation of the determinant of A.
a d - b c = Det[( ({{a, b}, {c, d  }})) ]

LHC.2) Solving 2D systems by hand via the Cramer's rule formula

Here is a 2D linear system:

A = {{Random[Integer, {1, 3}], 
            Random[Integer, {-3, 3}]}, {0.5 Random[
                Integer, {-3, 3}], 
            Random[Integer, {-8, -5}]}};
dim = 2;
Clear[x, y];
\(\(\(Y = {1, \(-1\)};\)\(
\)
    \)\)
linearsystem  =  
      ColumnForm[Thread[A . {x[1], x[2]}  ==   Y]]

Use the hand-style Cramer's rule to come up with the solution {x[1], x[2]}.

According to Cramer' 
          s rule : The solutions {x, y} of
(({{a, b}, {c, d}})).{x, y}={u, v}are given by

Clear[a, b, c, d, u, v]
{x, y}={((Det[( ({{u, b}, {v, d  }})) ])/(Det[( ({{a, b}, {c, d  }})) ]))   ,((Det[( ({{a, u}, {c, v }})) ])/(Det[( ({{a, b}, {c, d  }})) ]))}
{((d u - b v)/(-b c + a d)), ((-c u + a v)/(-b c + a d))}

Here we set (({{a, b}, {c, d}}))=(({{1., -3. }, {1.5, -8. }})) and {x,y} = {x[1],x[2]} and finally {u,v} = {1,-1}. Then

{x[1], x[2]}={((Det[( ({{1, -3. }, {-1, -8. }})) ])/(Det[( ({{1., -3. }, {1.5, -8.  }})) ]))   ,((Det[( ({{1, 1}, {1.5, -1}})) ])/(Det[( ({{1., -3. }, {1.5, -8.  }})) ]))}

LHC.3) Inverting a 2D matrices by hand via the Cramer's rule formula

Here is a 2D matrix:

A = {{Random[Integer, {1, 3}], 
            Random[Integer, {-3, 3}]}, {0.5 Random[
                Integer, {-3, 3}], 
            Random[Integer, {-8, -5}]}};
MatrixForm[A]

Use hand-style Cramer's rule to come up with the inverse of A.

From previous exercise we understand that the matrix we hit on {u,v} to get {x,y} is the inverse of (({{a, b}, {c, d}})).
From the output above, you can see that that matrix is:
              (((({{a, b}, {c, d}})))^(-1)) = (1/(a d  - b c))(({{d, -b}, {-c, a}}))
                      
                            =  (1/(Det[( ({{a, b}, {c, d  }})) ])) (({{d, -b}, {-c, a}}))
  
because  a d - b c = Det[( ({{a, b}, {c, d  }})) ]. Finally

(1/(Det[( ({{1., 2}, {-1.5, -6 }})) ]))( ({{-6, -2}, {1.5, 1 }}));
MatrixForm[%]