MGM.08 Subspaces, Spans , Dimension, Linear Independence, Basis, Orthonormal Bases
GIVE IT A TRY!

Needs["LinearAlgebra`MatrixManipulation`"];
Needs["LinearAlgebra`Orthogonalization`"];
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].";

Needs["Statistics`ContinuousDistributions`"];

Clear[matrixplucker];
matrixplucker[expr_, 
        vars_] := Simplify[
          Outer[D, {expr}, 
            vars]][[1]]

G.1) Visual linear independence and linear dependence

G.1.a.i) Two spanners in 3D

Here's a spanning set for a subspace S of 3D.

Clear[spanner, i];
spanner[1] = {1.2, -0.9, 1.5};
spanner[2] = {-0.4, 0.3, -0.5};
spanners = Table[spanner[i], {i, 1, 2}]

Here is a plot showing 
          s spanner[1] + t spanner[2]
for s and t running from -1  to 1 in increments of 0.5:

jump = 0.5;
Clear[spanplotter, r, s, t, vector1, 
        vector2, pointcolor];
pointcolor[s_, t_] = 
          RGBColor[0.5 (Sin[π s] + 1), 
            0.5 (Cos[π t] + 1), 0.00];

spanplotter[vector1_, vector2_] := 
          Table[Graphics3D[{PointSize[0.04], pointcolor[s, t], 
                Point[s vector1 + t vector2]}], {s, -1, 1, 
              jump}, {t, -1, 1, jump}];

spanplot=Show[spanplotter[spanner[1], spanner[2]],Axes3D[2],Axes -> True,AxesLabel -> {"x", "y", "z"},Boxed -> False,ViewPoint -> CMView];

See the same plot from the viewpoint of 12 spanner[1]:

Show[spanplot, ViewPoint -> 12 spanner[1]];

Making no calculations at all, fill the blank with either the word "dependent" or the word "independent:"
This visual evidence indicates to me that 
         {spanner[1], spanner[2]} 
is a linearly________________spanning set.

Making no calculations at all, fill the blank with the appropriate number.
This visual evidence indicates to me that the dimension of the subspace of 3D spanned by
         {spanner[1], spanner[2]} 
is ________________.

G.1.a.ii) Two new spanners in 3D

Here's a new spanning set for a subspace S of 3D.

Clear[spanner, i];
spanner[1] = {1.2, -0.9, 1.5};
spanner[2] = {1.4, 0.3, 0.5};
spanners = Table[spanner[i], {i, 1, 2}]

Here is a plot showing 
          s spanner[1] + t spanner[2]
for s and t running from -1  to 1 in increments of 0.25:

jump = 0.25;
Clear[spanplotter, r, s, t, vector1, 
        vector2, pointcolor];
pointcolor[s_, t_] = 
          RGBColor[0.5 (Sin[π s] + 1), 
            0.5 (Cos[π t] + 1), 0.00];

spanplotter[vector1_, vector2_] := 
          Table[Graphics3D[{PointSize[0.04], pointcolor[s, t], 
                Point[s vector1 + t vector2]}], {s, -1, 1, 
              jump}, {t, -1, 1, jump}];

spanplot=Show[spanplotter[spanner[1], spanner[2]],Axes3D[2],Axes -> True,AxesLabel -> {"x", "y", "z"},Boxed -> False,ViewPoint -> CMView];

See the same plot from the viewpoint of 12 spanner[1]:

Show[spanplot, ViewPoint -> 12 spanner[1]];

Making no calculations at all, fill the blank with either the word "dependent" or the word "independent:"
This visual evidence indicates to me that 
         {spanner[1], spanner[2]} 
is a linearly________________spanning set.

Making no calculations at all, fill the blank with the appropriate number.
This visual evidence indicates to me that the dimension of the subspace of 3D spanned by
         {spanner[1], spanner[2]} 
is ________________.

G.1.b.i) Three spanners in 3D

Here's a new spanning set for a subspace S of 3D.

Clear[spanner, i];
spanner[1] = {1.2, -0.9, 1.5};
spanner[2] = {0.4, 0.3, -1.5};
spanner[3] = {0.8, 0.4, 1.0};
spanners = Table[spanner[i], {i, 1, 3}]

Here is a plot showing 
          r spanner[1] + s spanner[2]  +  t spanner[3]
for r, s and t running from -1 to 1 in increments of 0.25:

jump = 0.25;
Clear[spanplotter, r, s, t, vector1, 
        vector2, vector3, pointcolor];
pointcolor[r_, s_, t_] = 
          RGBColor[0.5 (Sin[π r] + 1), 
            0.5 (Cos[π s] + 1), Sin[π t]^2];

spanplotter[vector1_, vector2_, vector3_] := 
          Table[Graphics3D[{PointSize[0.04], pointcolor[r, s, t], 
                Point[r vector1 + s vector2 + t vector3]}], {r, -1, 1, 
              jump}, {s, -1, 1, jump}, {t, -1, 1, jump}];

spanplot=Show[spanplotter[spanner[1], spanner[2], spanner[3]],Axes3D[3],Axes -> True,AxesLabel -> {"x", "y", "z"},Boxed -> False,ViewPoint -> CMView];

See the same plot from the viewpoint of 12 spanner[1]:

Show[spanplot, ViewPoint -> 12 spanner[1]];

See the same plot from the viewpoint of 12 spanner[2]:

Show[spanplot, ViewPoint -> 12 spanner[2]];

Show[spanplot, ViewPoint -> 12 spanner[3]];

Making no calculations at all, fill the blank with either the word "dependent" or the word "independent:"
This visual evidence indicates to me that 
         {spanner[1], spanner[2], spanner[3]} 
is a linearly________________spanning set.

Making no calculations at all, fill the blank with the appropriate number.
This visual evidence indicates to me that the dimension of the subspace of 3D spanned by
         {spanner[1], spanner[2], spanner[3]} 
is ________________.

G.1.b.ii) Three new spanners in 3D

Here's a new spanning set for a subspace S of 3D.

Clear[spanner, i];
spanner[1] = {1.2, -0.9, 1.5};
spanner[2] = {0.4, -0.3, 0.5};
spanner[3] = {-0.8, 0.6, -1.0};
spanners = Table[spanner[i], {i, 1, 3}]

Here is a plot showing 
          r spanner[1] + s spanner[2]  +  t spanner[3]
for r, s and t running from -1 to 1 in increments of 0.25:

jump = 0.25;
Clear[spanplotter, r, s, t, vector1, 
        vector2, vector3, pointcolor];
pointcolor[r_, s_, t_] = 
          RGBColor[0.5 (Sin[π r] + 1), 
            0.5 (Cos[π s] + 1), Sin[π t]^2];

spanplotter[vector1_, vector2_, vector3_] := 
          Table[Graphics3D[{PointSize[0.02], pointcolor[r, s, t], 
                Point[r vector1 + s vector2 + t vector3]}], {r, -1, 1, 
              jump}, {s, -1, 1, jump}, {t, -1, 1, jump}];

spanplot=spanplot=Show[spanplotter[spanner[1], spanner[2], spanner[3]],Axes3D[2],Axes -> True,AxesLabel -> {"x", "y", "z"},Boxed -> False,ViewPoint -> CMView];

See the same plot from the viewpoint of 12 spanner[1]:

Show[spanplot, ViewPoint -> 12 spanner[1]];

Making no calculations at all, fill the blank with either the word "dependent" or the word "independent:"
This visual evidence indicates to me that 
             {spanner[1], spanner[2], spanner[3]} 
is a linearly________________spanning set.
Making no calculations at all, fill the blank with the appropriate number.
This visual evidence indicates to me that the dimension of the subspace of 3D spanned by
         {spanner[1], spanner[2], spanner[3]} 
is ________________.

G.1.b.iii) Three more spanners in 3D

Here's a new spanning set for a subspace S of 3D.

Clear[spanner, i];
spanner[1] = {1.22, -0.52, 1.25};
spanner[2] = {-1.0, 0.56, 1.27};
spanner[3] = {0.11, 0.02, 1.26};
spanners = Table[spanner[i], {i, 1, 3}]

Here is a plot showing 
          r spanner[1] + s spanner[2]  +  t spanner[3]
for r, s and t running from -1 to 1 in increments of 0.25:

jump = 0.25;
Clear[spanplotter, r, s, t, vector1, 
        vector2, vector3, pointcolor];
pointcolor[r_, s_, t_] = 
          RGBColor[1, 0.5 (Cos[((π s)/2)] + 1), 
            Sin[((π t)/4)]^2];

spanplotter[vector1_, vector2_, vector3_] := 
          Table[Graphics3D[{PointSize[0.04], pointcolor[r, s, t], 
                Point[r vector1 + s vector2 + t vector3]}], {r, -1, 1, 
              jump}, {s, -1, 1, jump}, {t, -1, 1, jump}];

spanplot=Show[spanplotter[spanner[1], spanner[2], spanner[3]],Axes3D[3.5],Axes -> True,AxesLabel -> {"x", "y", "z"},PlotRange -> All,Boxed -> False,ViewPoint -> CMView];

See the same plot from the viewpoint of 12 spanner[1]:

Show[spanplot, ViewPoint -> 12 spanner[1]];

See the same plot from the viewpoint of 12 spanner[2]:

Show[spanplot, ViewPoint -> 12 spanner[2]];

See the same plot from the viewpoint of 12 spanner[3]:

Show[spanplot, ViewPoint -> 12 spanner[3]];

Making no calculations at all, fill the blank with either the word "dependent" or the word "independent:"
This visual evidence indicates to me that 
            {spanner[1], spanner[2], spanner[3]} 
is a linearly________________spanning set.

Making no calculations at all, fill the blank with the appropriate number.
This visual evidence indicates to me that the dimension of the subspace of 3D spanned by
         {spanner[1], spanner[2], spanner[3]} 
is ________________.

G.1.c.i)  2D

Here are two vectors X and Y in 2D:

X  =  {Random[Real, {-2, 2}], 
          Random[Real, {-2, 2}]};
\(\(Y\  = \ {Random[Real, {\(-2\), 2}], 
          Random[Real, {\(-2\), 2}]};\)
\)
\(\(twovectors\  = \ 
	
        Show[Arrow[X, Tail -> {0, 0}, 
            VectorColor -> 
              MediumVioletRed], 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Arrow[Y, 
            Tail -> {0, 0}, VectorColor -> TurquoiseBlue], 
		Axes -> 
            True, AxesLabel -> {"x", "y"}, 
		PlotRange -> {{\(-2\), 2}, {\(-2\), 2}}];\)\)

◼ Let your eyes make the call with no calculation whatsoever:
Is  {X,Y} a linearly independent spanning set?
Explain your position.
Put answer here.

◼ Here are the same two vectors X and Y plotted above shown with another random 2D vector Z

\(\(\(	\)\(Z\  = \ {Random[Real, {\(-2\), 2}], 
        Random[Real, {\(-2\), 2}]}; 
    Show[twovectors, 
      Arrow[Z, Tail -> {0, 0}, VectorColor -> Oak]];\)\)\)

Would it have been possible by a fluke or otherwise that the three plotted vectors {X,Y,Z} turned out to be a linearly independent spanning set? Why?

G.1.c.ii) Four random vectors in 3D

Here are four random vectors X,Y,Z and W in 3D:

X  =  {Random[Real, {-2, 2}], Random[Real, {-2, 2}], 
          Random[Real, {-2, 2}]};
Y  =  {Random[Real, {-2, 2}], Random[Real, {-2, 2}], 
          Random[Real, {-2, 2}]};
Z =  {Random[Real, {-2, 2}], Random[Real, {-2, 2}], 
          Random[Real, {-2, 2}]};
\(\(W\  = \ {Random[Real, {\(-2\), 2}], Random[Real, {\(-2\), 2}], 
          Random[Real, {\(-2\), 2}]};\)
\)
\(\ \(Show[
        Arrow[X, Tail -> {0, 0, 0}, 
          VectorColor -> Red], 
	\ \ \ \ \ \ \ \ \ \ \ Arrow[Y, 
          Tail -> {0, 0, 0}, 
          VectorColor -> NavyBlue], 
	\ \ \ \ \ \ \ \ \ \ \ Arrow[Z, 
          Tail -> {0, 0, 0}, 
          VectorColor -> DarkViolet], 
	\ \ \ \ \ \ \ \ \ \ \ Arrow[W, 
          Tail -> {0, 0, 0}, 
          VectorColor -> CadmiumOrange], 
	\ \ \ \ \ \ \ \ \ \ \ Axes3D[
          2], 
	\ \ \ \ \ \ \ \ \ \ \ Axes -> True, Boxed -> False, 
        AxesLabel -> {"x", "y", "z"}, 
\ \ \ \ \ \ \ \ \ \ \ \ \ PlotRange -> {{\(-2\), 2}, {\(-2\), 2}, {\(-2\), 2}}, 
        ViewPoint -> CMView];\)\)

Is this set of four plotted vectors {X,Y,Z,W} a linearly independent spanning set?
How do you know?

G.1.c.iii) 7D

Agree or disagree:
When you are given a spanning set consisting of 8 or more 7D vectors, then you know in advance that the given spanning set is not linearly independent.
Explain your response.

G.2) Dimension, bases and linear independence

G.2.a)  Calculate dimension and give an orthonormal basis

A subspace S of 7D is defined by this spanning set:

Clear[i, spanner];
spanner[1] = {-0.7, -3.8, 2.2, -3.1, -0.1, 
          2.2, -3.9};
spanner[2] = {1.8, 3.4, -1.6, -2.6, 2.4, -2.2, 
          2.0};
spanner[3] = {-4.3, -10.6, 5.4, 2.1, -4.9, 
          6.6, -7.9};
spanner[4] = {-5.7, -18.2, 9.8, -4.1, -5.1, 
          11. , -15.7};
spanner[5] = {-1.4, 0.6, -0.3, 0.0, 0.0, 0.0, 
          0.0};
\(\(\(spanners\)\(=\)\(Table[spanner[i], {i, 1, 5}]\)\(
\)\)\)

Calculate the dimension of S and give an orthonormal basis (perpendicular frame) that spans S.
Is the given spanning set linearly independent?

G.2.b)   Calculate dimension and give an orthonormal basis

A subspace S of 5D is defined by this spanning set:

Clear[i, spanner];
spanner[1] = {2.2, -3.1, -0.1, 2.2, -3.9};
spanner[2] = {-9.6, -5.6, 2.4, -1.2, 2.0};
spanner[3] = {5.4, 2.1, -4.9, 6.6, -7.9};
spanner[4] = {0.8, -4.1, -5.1, 0.0, -5.7};
spanners = Table[spanner[i], {i, 1, 4}]

Calculate the dimension of S and give an orthonormal basis (perpendicular frame) that spans S.
Is the given spanning set linearly independent?

G.2.c) S1 + S2 and S1⋂ S2

A subspace S1 of 7D is specified by the following spanning set:

Clear[i, spanner1];
spanner1[1] = {1.0, -2.3, -4.2, 2.2, 0.4, 0.8, 
          0.0};
spanner1[2] = {-3.8, 8.7, 15.5, -7.4, -1.2, -2.6, 
          1.3};
spanner1[3] = {-0.5, -0.3, 0.9, 0.4, -0.3, 0.2, 
          0.9};
\(\(spanner1[4] = {0.2, \(-0.5\), \(-1.3\), 1.4, 0.4, 0.6, 
          1.3};\)
\)
spanners1 = Table[spanner1[i], {i, 1, 4}]

Another subspace S2 of 7D  is specified by the following spanning set:

Clear[i, spanner2];
spanner2[1] = {-2.8, 6.4, 11.3, -5.2, -0.8, -1.8, 
          1.3};
spanner2[2] = {-0.1, -1.3, -1.7, 3.2, 0.5, 1.4, 
          3.5};
\(\(spanner2[3] = {1.7, 0.0, 5.2, \(-1.6\), \(-2.8\), \(-2.12\), 
          3.1};\)
\)
\(\(spanners2 = Table[spanner2[i], {i, 1, 3}];\)
\)
ColumnForm[spanners2]

◼ Give an orthonormal basis of S1 + S2.
Put answer here.

◼ Give an orthonormal basis of S1⋂ S2 
Put answer here.

G.2.d.i) Dimension

You are given an orthonormal set (perpendicular frame) of vectors
      {X[1], X[2], X[3], X[4], X[5]}   
 in 8D.
 The given set
       {X[1], X[2], X[3], X[4], X[5]} 
 spans a subspace S of 8D.
What is the dimension of S?

G.2.d.ii) All of 5D?

You are given a linearly independent set of vectors
      {X[1], X[2], X[3], X[4], X[5]}   
 in 5D.The given set
       {X[1], X[2], X[3], X[4], X[5]} 
 spans a subspace S of 5D.
Are there any 5D vectors {a,b,c,d,e} that are not in S?

G.2.e.i) Column space and row space

◼ Here's a matrix A:

A =  (({{2.3, 0.4, -2.1, 0}, {1.2, -2.4, 0.6, 0}, {2.9, -0.8, -1.8, 1.2}, {-2.3, -0.4, 2.1, -1.2}}));
MatrixForm[A]

The column space of A, R[A], consists of all possible hits with A. 
This is the same as the subspace of 4D spanned by the columns of A. 
Calculate the dimension of R[A].
Put answer here.

◼ Stay with the same matrix A

The row space of A, R[(A^t)], consists of all possible hits with (A^t).  This is the same as the subspace spanned by the rows of A. Calculate the dimension of the row space of A. 
Put answer here.

◼ Given any matrix A, clued-in matrix folks know that the dimension of the column space of A is the same as the dimension of the row space of A. 
How do they know this?
Put answer here.

◼ If A is a matrix that hits on 8D  and the rank of A is 6, then what is the dimension of the column space of A?
Put answer here.

◼ If A is a matrix that hits on 8D and the rank of A is 6, then what is the dimension of the row space of A?

G.3) Redundant spanning vectors; paring down to a basis

G.3.a.i) A basis?

Here's a set of vectors in 7D:

Clear[spanner, i];
spanner[1] = {1.2, -2.6, 5.7, 0.7, -1.9, -7.0, 
          2.9};
spanner[2] = {0.3, 3.3, -2.6, -3.7, 6.8, 5.0, 
          6.4};
spanner[3] = {2.3, 5.1, 5.3, 4.7, 
          1.9, -2.8, -1.2};
spanner[4] = {1.3, 0.0, 1.3, 0.7, -3.5, 8.0, 0.0};
spanner[
          5] = {0.4, -3.0, -4.8, -9.2, -8.6, -4.7, -2.9};
spanners = Table[spanner[i], {i, 1, 5}]

This spanning set spans a subspace S of 7D.
Is the given spanning set a basis of S?
If not reduce this spanning set to a basis of S by identifying and throwing away the redundant vectors.

G.3.a.ii) A basis?

Here's a set of vectors in 8D:

Clear[spanner, i];
spanner[1] = {1.0, -2.5, 5.0, 0.5, -1.0, -7.5, 2.0, 
          0.5};
spanner[2] = {0.3, 3.3, -2.6, -3.7, 6.8, 5.0, 
          6.4, -9.3};
spanner[3] = {1.0, 5.4, 5.4, 4.8, 1.0, -2.8, -1.8, 
          0.0};
spanner[4] = {0.7, 2.2, 3.7, 2.5, 0.3, -2.9, -0.5, 
          0.1};
spanner[5]  =  {1.0, 5.4, 5.4, 4.8, 1. , -2.8, -1.8`, 
          0};
spanner[
          6] = {0.4, -3.0, -4.8, -9.2, -8.6, -4.7, -2.9, 0.8};
spanner[7] = {3.5, -6.8, -2, 8, -0.8, 4.3, 
          6.5, -0.9};
\(\(\(spanners\)\(=\)\(Table[spanner[i], {i, 1, 7}]\)\(
\)\)\)

This spanning set spans a subspace S of 8D.
Is the given spanning set a basis of S?
If not reduce this spanning set to a basis of S by identifying and throwing away the redundant vectors.

G.3.a.iii) Not a basis

Here's a set of vectors in 7D:

Clear[spanner, i];
spanner[1] = {1.0, -2.5, 5.0, 0.5, -1.0, -7.5, 
          2.0};
spanner[2] = {0.3, 3.3, -2.6, -3.7, 6.8, 5.0, 
          6.4};
spanner[3] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
spanner[4] = {0.7, 2.2, 3.7, 2.5, 
          0.3, -2.9, -0.5};
spanner[
          5] = {0.4, -3.0, -4.8, -9.2, -8.6, -4.7, -2.9};
spanner[6] = {3.5, -6.8, -2, 8, -0.8, 4.3, 
          6.5};
\(\(spanners = Table[spanner[i], {i, 1, 6}];\)
\)
ColumnForm[spanners]

This spanning set spans a subspace S of 8D.
.Note that spanner[3] is the vector of all zeroes:

spanner[3]

How does this signal in advance that this spanning set is not a basis of S?

G.3.a.iv) Too many

Agree or disagree:
When you are given a spanning set consisting of eight 7D vectors, then you know in advance that at least one of the given spanner set is redundant in the sense that if you remove it from the spanning set,then the remaining spanners span the same subspace as the original spanning set.

G.4) Calculus Cal screws up again

G.4.a) Dimension

A subspace S of 9D is defined by:

Clear[i, spanner];
spanner[1] = {-3.5, -1.8, -0.7, -3.8, 
          2.2, -3.1, -0.1, 2.2, -3.9};
spanner[2] = {-3.2, -0.4, 1.8, 3.4, -1.6, -2.6, 
          2.4, -2.2, 2.0};
spanner[3] = {-5.1, -2.0, 0.2, -2.1, 1.4, -4.4, 1.1, 
          1.1, -2.9};
spanner[4] = {-13.1, -3. , 4.7, 6.4, -2.6, -10.9, 
          7.1, -4.4, 2.1};
\(\(\(spanners\)\(=\)\(Table[spanner[i], {i, 1, 4}]\)\(
\)\)\)

When Calculus Cal looked at this, he said: "This subspace S of 9D is a four dimensional subspace." 
You said: "Where did you get that idea?"
Cal said: " Stupid question. I say S is four dimensional because it is spanned by the four given spanning vectors."
What's your reply?
Is S in fact four dimensional?

G.4.b) Are two subspaces S1 and S2 in fact different?

A subspace S1 of 3D is defined by:

Clear[i, spanner1];
spanner1[1] = {0.43, -1.57, 3.13};
spanner1[2] = {0.97, 1.29, 0.83};
spanners1 = Table[spanner1[i], {i, 1, 2}]

Here's a another set of spanning vectors which define a subspace S2 of 3D:

Clear[i, spanner2];
spanner2[1] = {1.4, -0.28, 3.96};
spanner2[2] = {-1.08, -5.72, 4.6};
spanners2 = Table[spanner2[i], {i, 1, 2}]

When Calculus Cal looked at this, he said: "The two subspaces S1 and S2 of 3D are not the same because different spanning sets lead to different subspaces."
What's your reaction to Cal's position?
Are the two subspaces S1 and S2 in fact different?
How do you know?

G.4.c) A set of random vectors

A subspace S of 6D is defined by the following seven random vectors:

Clear[i, j, spanner];
spanner[1] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[2] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[3] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[4] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[5] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[6] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanner[7] = 
        Table[Random[Real, {-10, 10}], {i, 1, 6}];
spanners = Table[spanner[i], {i, 1, 7}]

When Calculus Cal looked at this, he said: "I have noticed that sets of randomly generated vectors almost always turn out to be linearly independent."
You say: "Cal, there is no way the spanning set above could turn out to be linearly independent."
Why did you say this?

G.4.d) Linear independence

Another day in the lab, Calculus Cal was working with the following spanning set for a subspace S of 4D.

Clear[i, j, spanner];
spanner[1] = {1.0, 0.0, 0.0, -1.0};
spanner[2] = {1.0, 1.0, 0.0, 1.0};
spanner[3] = {1.0, 1.0, 1.0, -1.0};
spanners = Table[spanner[i], {i, 1, 3}]

He checked the dimension of S :

\(\(SpannerMatrix = Transpose[spanners];\)
\)
Sdim = 
      Length[SingularValues[
            SpannerMatrix][[2]]]

And then he announced (correctly) that this spanning set is linearly independent. Then he went on to say : 
"The given spanning set 
         {spanner[1], spanner[2], spanner[3]}
 is linearly independent, so spanner[1] is linearly independent, spanner[2] is linearly independent and spanner[3] is linearly independent." 
What did you say to Cal?

G.5) Closest points

G.5.a) 3D

A subspace S of 3D is defined by:

Clear[i, spanner];
spanner[1] = {-1.0, 0.0, 1.0};
\(\(spanner[2] = {0.0, 1.0, 0.7};\)
\)
spanners = Table[spanner[i], {i, 1, 2}]

This subspace of 3D is a plane and it's easy to plot a piece of it.

h = 1;
k = 1;
Clear[s, t];
\(\(subspaceplot = 
        ParametricPlot3D[
          s\ spanner[1] + t\ spanner[2], {s, \(-h\), h}, {t, \(-k\), k}, 
          PlotPoints -> {2, 2}, 
          DisplayFunction -> Identity];\)
\)
\(\(subspacelabel = 
        Graphics3D[{CadmiumOrange, 
            Text["S", 
              spanner[1] + spanner[2] + {0, 0, 0.3}]}];\)
\)
setup = 
        Show[subspaceplot, subspacelabel, ThreeAxes[2], 
          ViewPoint -> CMView, PlotRange -> All, Axes -> True, 
          AxesLabel -> {"x", "y", "z"}, Boxed -> False, 
          PlotLabel -> "Piece of S", 
          DisplayFunction -> $DisplayFunction];

Here is the plane shown with a point not on the plane.

point = {0.2, 0.3, 1.5};
\(\(pointplot = 
        Graphics3D[{Red, PointSize[0.03], Point[point]}];\)
\)
Show[setup, pointplot, 
        PlotLabel -> "S and point"];

Use the Sprojection matrix to come up with the point on the plane closest to the given plotted point. Show off your work by adding this point to the plot above.

G.5.b) Projecting a circle

Here's a plot of a subspace S of 3D:

spanners = {{1.1, 1.2, 0}, {-1, 1.2, 1.0}};
SpannerMatrix = Transpose[spanners];
\(\(h = 7;\)
\)
\(\(subspaceplot = 
        Graphics3D[
          Polygon[{SpannerMatrix . {h, h}, SpannerMatrix . {h, \(-h\)}, 
              SpannerMatrix . {\(-h\), \(-h\)}, 
              SpannerMatrix . {\(-h\), h}}]];\)
\)
\(\(subspacelabel = 
        Graphics3D[{CadmiumOrange, 
            Text["S", 1.2\ SpannerMatrix . {\(-h\), h}]}];\)
\)
setup = 
        Show[subspaceplot, subspacelabel, Axes3D[1.5 h], 
          ViewPoint -> CMView, 
          DisplayFunction -> $DisplayFunction];

Throw in the plot of this circular disk:

{rlow, rhigh} = {0, 6};
{tlow, thigh} = {0, 
          2 π};
center = {3, 4, 10};

Clear[diskplotter, r, t];
diskplotter[r_, t_] = {r Cos[t], r Sin[t], 0} + center;

diskplot=ParametricPlot3D[diskplotter[r, t],{r, rlow, rhigh},{t, tlow, thigh},PlotPoints -> {2, Automatic},DisplayFunction -> Identity];

setup = 
        Show[subspaceplot, diskplot, ThreeAxes[2 h, (h/6)], 
          ViewPoint -> CMView, 
          DisplayFunction -> $DisplayFunction];

Imagine that light is coming from way above the plane in rays all perpendicular to the plane. 
Come up with a matrix A so that
         A . diskplotter[r, t]
plots out the shadow of the disk on the plane.
Show off your work with a decisive plot.

G.5.c) In or out?

◼ A subspace S of 4D is defined by this spanning set:

Clear[i, spanner];
spanner[1] = {-1.0, -0.6, 0.8, 0.0};
spanner[2] = {2.4, -0.8, 0.8, 0.4};
spanner[3] = {-5.1, -2.0, 0.2, -2.1};
spanners = Table[spanner[i], {i, 1, 3}]

Here is a 4D vector X

X = {8.2, -1.8, 1.6, 1.2}

Is X in S?
If not come up with the member of S that is closest to X.
Put answer here.

◼ A new subspace S of 4D is defined by this spanning set:

Clear[i, spanner];
spanner[1] = {-1.0, -0.6, 0.8, 0.0};
spanner[2] = {2.4, -0.8, 0.8, 0.4};
spanner[3] = {-5.1, -2.0, 0.2, -2.1};
spanners = Table[spanner[i], {i, 1, 3}]

Here is a 4D vector X

X = {8.2, 1.8, 1.6, 1.2}

Is X in S?
If not come up with the member of S that is closest to X.
Put answer here.

◼ Here is a spanning set for a random subspace S of 7D

dim = 7;
Clear[j, k, spanner];
number = Random[Integer, {3, 6}];
spanners = 
      Table[spanner[k] = Table[Random[Real, {-2, 2}], {j, 1, dim}], {k, 
          1, number}]

Here is a random 7D vector:

X = Table[Random[Real, {-2, 2}], {k, 1, dim}]

Is X in the subspace S?
If not, then come up with a 7D vector Y so that 
        Y.X ≠ 0 
but
         Y.Z = 0 for all Z in S.

After you've come up with your shot at Y, you can check whether
         Y.Z = 0 for all Z in S 
simply by checking whether 
          Y.spanner[k] = 0 for all k.

G.6) Orthonormal bases: Gram-Schmidt versus SVD

G.6.a) Orthonormal bases: Gram-Schmidt versus SVD

◼ Here is a spanning set for a random subspace S of 5D

dim = 5;
Clear[j, k, spanner];
number = Random[Integer, {3, 4}];
spanners = (Table[
          spanner[k] = Table[Random[Real, {-2, 2}], {j, 1, dim}], {k, 1, 
            number}])

Here is the orthonormal basis of S that you get from applying the Gram-Schmidt process to the given spanning set:

gramspanner[k_]  := GramSchmidt[ spanners][[k]]
gramorthospanners =  
      Table[gramspanner[k], {k, 1, 
          Length[GramSchmidt[ spanners]]}]

Here is the orthonormal basis for S that you get from the SVD hanger frame of the SpannerMatrix:

SpannerMatrix = Transpose[spanners];
rank = 
        Length[SingularValues[
              SpannerMatrix][[2]]];
\(\(Sdim = rank;\)
\)
Clear[SVDperpframe, k];
\(\(SVDperpframe[
          k_] := \(\(SingularValues[
              SpannerMatrix]\)[[1]]\)[[k]];\)
\)
SVDorthospanners = Table[SVDperpframe[k], {k, 1, Sdim}]

Notice that the two orthonormal bases for S are not at all the same.
Do you have a problem with this? Why or why not?
Put answer here.

◼ Above you see three bases of S:

spanners

gramorthospanners

SVDorthospanners

Each of the three bases of S contains the same number of vectors.
Why was that guaranteed to happen?
Put answer here.

◼  Each of these three bases for S gives rise to a spanner matrix for S:

SpannerMatrix1  =  Transpose[spanners];
MatrixForm[SpannerMatrix1]

SpannerMatrix2  =  Transpose[gramorthospanners];
MatrixForm[SpannerMatrix2]

SpannerMatrix3  =  Transpose[SVDorthospanners];
MatrixForm[SpannerMatrix3]

Now look at the Sprojection matrices coming from each of the bases:

Sprojection1 = 
        SpannerMatrix1 . PseudoInverse[SpannerMatrix1];
MatrixForm[Sprojection1]

Sprojection2 = 
        SpannerMatrix2 . PseudoInverse[SpannerMatrix2];
MatrixForm[Sprojection2]

Sprojection3 = 
        SpannerMatrix3 . PseudoInverse[SpannerMatrix3];
MatrixForm[Sprojection3]

Study the outputs and explain why you could have predicted the results in advance.
Put answer here.

◼ Keep everything the same as above and throw in this random 5D vector X.

X = Table[Random[Real, {-2, 2}], {k, 1, dim}]

Look at these calculations:

SpannerMatrix  =  
        Transpose[spanners];
Sprojection = 
        SpannerMatrix . PseudoInverse[SpannerMatrix];
SclosestX  =  Sprojection . X

m  =  Length[GramSchmidt[spanners]];
(∑_(k = 1)^m)(X . gramspanner[k]) gramspanner[k]

(∑_(k = 1)^Sdim)(X . SVDperpframe[k]) SVDperpframe[k]

Surely these outcomes were not accidents. 
Explain why they were not accidents.

G.7) Some features of Sprojection matrices

G.7.a)  Sprojection.Sprojection =  Sprojection

Here's a spanning set for a random subspace S of 6D:

Clear[a, i, j, spanner];
a[i_, j_] := Random[Real, {-3, 3}];
spanner[i_] := Table[a[i, j], {j, 1, 6}];
number = Random[Integer, {2, 5}];
spanners = Table[spanner[i], {i, 1, number}]

The Sprojection matrix for this subspace S of 6D is:

SpannerMatrix = Transpose[spanners];
Sprojection = SpannerMatrix.PseudoInverse[SpannerMatrix] ;
MatrixForm[Sprojection]

Now look at Sprojection.Sprojection:

MatrixForm[Sprojection . Sprojection]

It turned out that 
    Sprojection . Sprojection = Sprojection.
Explain why this happened and why this will always happen.

Given a 6D vector X, you know that Sprojection.X is the closest member of S to X. 
So the problem boils down to explaining why
         Sprojection.(Sprojection.X) = Sprojection.X
 for all 6D vectors X.

G.7.b) Sprojection is also a SpannerMatrix for S.  In other words, the columns of Sprojection span S

Here's a spanning set for a random subspace S of randomD:

dim = Random[Integer, {3, 5}];
Clear[j, k, spanner];
\(\(number = Random[Integer, {2, 5}];\)
\)
spanners = 
      Table[spanner[k] = Table[Random[Real, {-2, 2}], {j, 1, dim}], {k, 
          1, number}]

The dimension of this subspace S is:

SpannerMatrix  =  Transpose[spanners]; 
    Sdim  =  Length[SingularValues[SpannerMatrix][[2]]]

The Sprojection matrix for S is:

Sprojection = 
        SpannerMatrix . PseudoInverse[SpannerMatrix];
MatrixForm[Sprojection]

Why are you guaranteed that each vertical column of Sprojection is in S?
Why are you guaranteed that the set of vertical columns of Sprojection is a spanning set for S?

G.7.c) (dimension of S) = (rank of Sprojection).

Here's a spanning set for a random subspace S of randomD:

dim = Random[Integer, {3, 5}];
Clear[j, k, spanner];
\(\(number = Random[Integer, {2, dim\  - \ 1}];\)
\)
spanners = 
      Table[spanner[k] = Table[Random[Real, {-2, 2}], {j, 1, dim}], {k, 
          1, number}]

The dimension of this subspace S is:

SpannerMatrix  =  Transpose[spanners]; 
    Sdim  =  Length[SingularValues[SpannerMatrix][[2]]]

The Sprojection matrix for S is:

Sprojection = 
        SpannerMatrix . PseudoInverse[SpannerMatrix];
MatrixForm[Sprojection]

Now look at this calculation of the rank of 
          Sprojection:

rankSprojection  =  
      Length[SingularValues[Sprojection][[2]]]

Sdim == rankSprojection

It turned out that  
       dimension of S = (rank of Sprojection).
Was this an accident?
If not, try to explain why it had to happen this way.

G.7.d) Sprojection = (Sprojection^t)

Here's a spanning set for a random subspace S of 5D:

dim = 5;
Clear[j, k, spanner];
number = Random[Integer, {2, 4}];
spanners = 
      Table[spanner[k] = Table[Random[Real, {-2, 2}], {j, 1, dim}], {k, 
          1, number}]

Here is the Sprojection matrix calculated through SVD of the SpannerMatrix:

dim = Length[SingularValues[SpannerMatrix][[2]]];
Clear[hangerframe, rankOne];
aligner = SingularValues[SpannerMatrix][[1]];
stretcher  =  IdentityMatrix[dim];
hanger = Transpose[SingularValues[SpannerMatrix][[1]]];

Sprojection = hanger.stretcher.aligner;
MatrixForm[
      Sprojection]

Now look at this calculation of 
          (Sprojection^t):

MatrixForm[Transpose[Sprojection]]

It turned out that
            Sprojection = (Sprojection^t).
Was this an accident?
If not, try to explain why it had to happen this way.

When you make the Sprojection, you use the same perpendicular frame for your aligner frame and the hanger frame.

G.7.e) SVD stretch factors of Sprojections

Here's a spanning set for a random subspace S of 8D:

Clear[a, i, j, spanner];
a[i_, j_] := Random[Real, {-3, 3}];
spanner[i_] := Table[a[i, j], {j, 1, 8}];
number = Random[Integer, {4, 6}];
spanners = Table[spanner[i], {i, 1, number}]

The Sprojection matrix for this subspace S of 6D is:

SpannerMatrix = Transpose[spanners];
Sprojection = SpannerMatrix.PseudoInverse[SpannerMatrix] ;
MatrixForm[Sprojection]

The non-zero SVD stretch factors of Sprojection are:

stretches  =  SingularValues[Sprojection][[2]]

It turned out that the SVD stretch factors of this Sprojection matrix are all either 0 or 1.

Explain this bold statement:
If S is any subspace of kD, then it is sure that the SVD stretch factors of the corresponding Sprojection matrix are all either 0 or 1.

G.7.f) S1projection . S2Projection

You are given two subspaces S1 and S2 of kD. 
◼What relationship between S1 and S2 do you get if it turns out that
            S2Projection.S1Projection = S2Projection? 
Put answer here.

◼What relationship between S1 and S2 do you get if it turns out that
            S2Projection.S1Projection = S1Projection? 
Put answer here.

G.8)  S1 + S2, S1⋂ S2 and related issues

G.8.a.i)   S1 + S2

A subspace S1 of 7D is specified by the following spanning set:

Clear[i, 
        spanner1];
spanner1[1] = {0.0, -0.3, -0.2, 0.2, 
          0.4, 0.4, 0.5};
spanner1[2] = {0.9, 0.8, 0.7, 0.4, 
          0.0, -0.1, 0.0};
spanner1[3] = {-0.5, -0.3, 
          0.9, 0.4, -0.3, 0.2, -0.5};
spanner1[4] = {1.4, 
          0.8, -0.4, 0.2, 0.7, 0.1, 
          1. };
spanner1[5] = {1.0, 1.0, 0.0, 
          0.0, 0.0, 0.0, 1.0};
spanners1=Table[spanner1[i], {i, 1, 5}]

Another subspace S2 of 7D  is specified by the following spanning set:

Clear[j, 
        spanner2];
spanner2[1] = {0.2, -0.5, -0.3, 0.4, 
          0.4, -0.8, 0};
spanner2[2] = {0.4, 0.2, 1.4, 1. , 
          0.1, 0.5, 0};
spanner2[3]  =  {0.0, 
          0.0, 1.0, 0, -1.0, 0.5, 
          0.0};
spanner2[4]  =  {0.3, 
          0, -0.2, 0.2, 0.4, 0.4, 
          0.8};
spanner2[
          5]  =  {-4.3, -2.5, 3.5, 0.8, -2.3, 
          0.4, -3.5};
spanners2=Table[spanner2[j], {j, 1, 5}]

▪ Calculate:
 The dimension of S1, the dimension of S2 and the dimension of S1 + S2.
Put answer here.

▪ Exhibit an orthonormal basis of S1 + S2. 
And come up with the Sprojection matrix for S1 + S2.

G.8.a.ii)  S1⋂ S2

Stay with the same subspaces S1 and S2 of 7D defined in the last part.

Come up with an orthonormal basis for S1 ⋂ S2 and use the result to calculate the dimension of S1 ⋂ S2.
Come up with the  S1⋂S2Projection matrix.

G.8.a.iii) In S2 but also in (((S1  ⋂  S2 ))^⊥)

Go back and look at your work in part ii).
 See whether it produced, as a by- product a non-zero vector that is In S2 but perpendicular to everything in 
           S1 ⋂ S2 .
 Identify this vector and say how you know it meets the specifications.

G.9) Alien plots coming from projections of highD surfaces onto three dimensional subspaces

G.9.a) f[s,t] = {Sin[s] Cos[t], Sin[s] Sin[t], Cos[s],Cos[t],Sin[t]}

Here's a 5D function f[s,t]:

Clear[f, s, t];
f[s_, t_]  =  {Sin[s] Cos[t],  Sin[s] Sin[t],  Cos[s], Cos[t], 
        Sin[t]}

Look at
           f[s, t] . f[s, t]:

Simplify[f[s, t] . f[s, t]]

▪What does this calculation tell you about where f[s,t] plots out in 5D?
Put answer here.

Stay with the same 5D function f[s,t]:

\(Clear[f, s, t]; 

    f[s_, t_]\  = 
      \ {Sin[s]\ Cos[t], \ Sin[s]\ Sin[t], \ Cos[s], Cos[t], Sin[t]}\)

When you run s and t from 0 to 2 Pi or (other choices you find revealing), you get a 5D surface which is piece of a 5D sphere centered at {0,0,0,0,0}.
Generate some random 3D subspaces of 5D and plot the projections of this 5D surface onto them.
Make a gallery of some of the really interesting ones you see.

G.9.b) Trying to plot a 6D function

Here's a 6D function f[s,t]:

\(Clear[f, s, t]; 

    f[s_, t_]\  = 
      \ {Sin[s]\ Cos[t], \ Sin[s]\ Sin[t], \ Cos[s], Sin[t]\ Cos[s], \ 
        t\  + Sin[t]\ , \ Cos[t]}\)

Look at
           f[s, t] . f[s, t]:

Simplify[f[s, t] . f[s, t]]

This tells you that f[s,t] does not plot out on the surface of a 6D sphere centered at {0,0,0,0,0,0}.
Still,when you run s and t from 0 to 2 Pi or (other choices you find revealing), you get a 6D surface.
Generate some random 3D subspaces of 6D and plot the projections of this 6D surface onto them.
Make a gallery of some of the really interesting ones you see.
You might want to cut back the plotting intervals on s and t.

G.9.c) Turn yourself loose - soar with the eagles

Come up with the most interesting plot you can by making 4D,5D or 6D function f[s,t] (not necessarily plotting out on a sphere) and projecting its plot onto a 3D subspace of your own choice. 
The wilder, the better.

G.10) Describing some subspaces

G.10.a) The vectors of the form  {x, y, z, w} with x = y
constitute a subspace of subspace S of 4D

Some folks like to specify subspaces qualitatively.
For instance the vectors of the form 
          {x, y, z, w} with x = y
constitute a subspace of subspace S of 4D. 
A spanning set for S is:

Clear[s, i, spanner];
spanner[1] = {1.0, 1.0, 0.0, 0.0};
spanner[2] = {1.0, 1.0, 1.0, 0.0};
spanner[3] = {1.0, 1.0, 0.0, 1.0};
\(\(spanners = Table[spanner[i], {i, 1, 3}];\)
\)
ColumnForm[spanners]

Here are some random members of S:

a = 1;
Clear[x];
\(\(\(x[i_]\)\(:=\)\(Random[Real, {\(-a\), a}]\)\(
\)\)\)
(∑_(i = 1)^(Length[spanners]))x[i] spanner[i]

a = 3; \(Clear[x]; 
x[i_] := Random[Real, {\(-a\), a}]
\)(∑_(i = 1)^(Length[spanners]))x[i] spanner[i]

a = 5; \(Clear[x]; 
x[i_] := Random[Real, {\(-a\), a}]
\)(∑_(i = 1)^(Length[spanners]))x[i] spanner[i]

Come up with a perpendicular frame that spans S.
▪Use the result to determine the dimension of S.
Put answer here.

▪Go with this 4D X:

X = {1.0, 3.0, 1.53, 0.78}

Come up with the member of S that is closest to X.

G.10.b) The vectors of the form 
         {y[1], y[2], y[3], y[4], y[5]} with y[1] = 0
constitute a subspace S of 5D

The vectors of the form 
         {y[1], y[2], y[3], y[4], y[5]} with y[1] = 0.
constitute a subspace S of 5D. 
▪ Give a spanning set for S.
Put answer here.

▪ Give perpendicular basis for S.
Put answer here.

▪ Go with this 5D X:

X = {1.2, -3.6, 1.53, 0.78, 12.0}

Come up with member of S that is closest to X.

G.10.c) The vectors of the form 
      {y[1], y[2], y[3], y[4], y[5]}
with  
      1.5 y[1] - 2.7 y[5] = 0 
and
      1.3 y[1] + 0.7 y[2] - 3.1 y[3] = 0
constitute a subspace S of 5D.

The vectors of the form 
      {y[1], y[2], y[3], y[4], y[5]}
with  
      1.5 y[1] - 2.7 y[5] = 0 
and
      1.3 y[1] + 0.7 y[2] - 3.1 y[3] = 0
constitute a subspace S of 5D. 
▪Give a spanning set for S.
Put answer here.

S is made of vectors of the form 
      {y[1], y[2], y[3], y[4], y[5]}
with  
      1.5 y[1]-2.7 y[5]=0 
and
      1.3 y[1] + 0.7 y[2] - 3.1 y[3] = 0

 Look at this matrix :

A=(({{1.5, 0, 0, 0, -2.7}, {1.3, 0.7, -3.1, 0, 0}}));

MatrixForm[
      A]

Check this out:

Clear[y];
ColumnForm[
      Thread[A . {y[1], y[2], y[3], y[4], y[5]}  ==  {0, 0}]]

Now look at:

NullSpace[A]

▪Then give an orthonormal basis (spanning set) for S.
Put answer here.
▪Calculate the dimension of S.

G.10.d) Another one

The vectors of the form 
      {y[1], y[2], y[3], y[4], y[5], y[6]}
with  
 {1.2, -0.7, 3.0, 0.0, -4.0, 3.0} 
          • {y[1], y[2], y[3], y[4], y[5], y[6]} = 0,
 
{0.5, -0.5, 0.5, 0.3, 3.2, -1.7} 
          • {y[1], y[2], y[3], y[4], y[5], y[6]} = 0

and
 {0.6, 0.2, -1.8, 0.0, 5.2, 0.8} 
          • {y[1], y[2], y[3], y[4], y[5], y[6]} = 0  
 
constitute a subspace S of 6D. 
Give a spanning set for S.
Exhibit some members of S.
Then give an orthonormal basis (spanning set) for S.
Calculate the dimension of S.

G.10.e.i) Do the vectors of the form
      {y[1], y[2], y[3], y[4]} 
with  
       y[1] + y[2] = 15.9
constitute a subspace of 4D?

Do the vectors of the form
      {y[1], y[2], y[3], y[4]} 
with  
       y[1] + y[2] = 15.9
constitute a subspace of 4D?
If your answer is yes, then give a perpendicular spanning set for this subspace.
If your answer is no, then say why the vectors described above do not constitute a subspace of 4D.

{0,0,0,0} is in every subspace of 4D.

G.10.e.ii) Do the vectors of the form
       {y[1], y[2], y[3], y[4]} 
with  
        y[2] = y[1]^2
constitute a subspace of 4D?

Do the vectors of the form
       {y[1], y[2], y[3], y[4]} 
with  
        y[2] = y[1]^2
constitute a subspace of 4D?
If your answer is yes, then give a perpendicular spanning set for this subspace.
If your answer is no, then say why the vectors described above do not constitute a subspace of 4D.

G.11) When you hit a whole subspace with a matrix, you get another subspace

G.11.a.i) A hitting a subspace with a matrix

Go with a random subspace S of 6D  specified via the following spanning set:

Clear[spanner, j];
spanner[1] = Table[Random[Real, {-3, 3}], {j, 1, 6}];
spanner[2] = Table[Random[Real, {-3, 3}], {j, 1, 6}];
spanner[3] = Table[Random[Real, {-3, 3}], {j, 1, 6}];
spanner[4] = Table[Random[Real, {-3, 3}], {j, 1, 6}];
\(\(spanners = Table[spanner[j], {j, 1, 4}];\)
\)
ColumnForm[spanners]

The spanner matrix is:

SpannerMatrix = Transpose[spanners];
MatrixForm[SpannerMatrix]

The subspace S consists of all possible hits with the spanner matrix:

hitdim = 4;
Clear[x, j];
\(\(X = Table[x[j], {j, 1, hitdim}];\)
\)
SpannerMatrix . X

Here comes a random matrix which hits on 6D and hangs in 7D.

Clear[a, i, j];
hitdim = 6;
hangdim = 7;
\(\(a[i_, j_] := Random[Real, {\(-2\), 2}];\)
\)
A = Table[a[i, j], {i, 1, hangdim}, {j, 1, hitdim}];
MatrixForm[A]

When you hit everything in S with A you get everything of the form:

A . SpannerMatrix . X

This results in a subspace AS of 7D. Use the matrix product

product = A . SpannerMatrix;
MatrixForm[product]

to come up with a spanning set for AS.
Calculate the dimension of S and calculate the dimension of AS.

G.11.a.ii) Hitting another subspace with another matrix

Go with a random subspace S of 5D  specified via the following spanning set:

Clear[spanner, j];
spanner[1] = Table[Random[Real, {-3, 3}], {j, 1, 5}];
spanner[2] = Table[Random[Real, {-3, 3}], {j, 1, 5}];
spanner[3] = Table[Random[Real, {-3, 3}], {j, 1, 5}];
\(\(spanners = Table[spanner[j], {j, 1, 3}];\)
\)
ColumnForm[spanners]

Here comes a  matrix A which hits on 5D and hangs in 4D.

A=(({{2.0, 0.5, 0.0, 4.0, 0.0}, {1.0, 0.0, -0.8, 0.6, 0.2}, {3.0, -0.4, 1.3, -0.4, 0.7}, {4.5, 1.0, -0.4, 8.3, 0.1}}));
MatrixForm[
      A]

When you hit everything in S with A you get a  subspace AS of 4D .
Calculate the dimension of S and calculate the dimension of AS.

G.11.b) General questions

When you hit a subspace S of kD with a matrix A that hits on kD and hangs in nD, you get a subspace of AS of nD.
Give your reactions to the following questions.
No explanation is required but if you want to throw one in please do.

◼ Is it possible for the dimension of AS to be greater than the dimension of S?
Put response here.

◼ If S is contained in the null space N[A] of A, what to you expect the dimension of AS to be?
Put response here.

◼ Is it possible for the dimension of AS to be strictly less than the dimension of S?
Put response here.

◼ If S ⋂ N[A] = {0,0,...,0},what to you expect the dimension of AS to be?
Put response here.

◼ If A is of full rank, how do you express the dimension of AS in terms of the dimension of S?
Put response here.

G.12) The perpendicular complement of a subspace of kD

G.12.a) Vector in  (S^⊥) closest to X

Go with a random subspace S of 7D  specified via the following spanning set:

Clear[spanner, j];
spanner[1] = Table[Random[Real, {-3, 3}], {j, 1, 7}];
spanner[2] = Table[Random[Real, {-3, 3}], {j, 1, 7}];
spanner[3] = Table[Random[Real, {-3, 3}], {j, 1, 7}];
spanner[4] = Table[Random[Real, {-3, 3}], {j, 1, 7}];
\(\(spanners = Table[spanner[j], {j, 1, 4}];\)
\)
ColumnForm[spanners]

Here is a random  7D vector X:

X  =  
      Table[Random[Real, {-3, 3}], {j, 1, 7}]

The vector in S that is closest to X is:

SpannerMatrix  =  Transpose[spanners];
Sprojection = 
        SpannerMatrix . PseudoInverse[SpannerMatrix];
SclosestX  =  Sprojection . X

Come up with the vector in  (S^⊥) that is closest to X.

G.12.b.i)  X - Sprojection.X is in (S^⊥)

When you go with a subspace S of kD, you can take any kD vector X and find the vector Sclosest in S that is closest to X by setting  
           SclosestX = SprojectionX.
This makes it automatic that
            X - SclosestX  = X - Sprojection.X 
is in (S^⊥).
Why is this automatic?

G.12.b.ii)  S + (S^⊥)

When you go with a subspace S of kD, you can take any kD vector X and find the vector Sclosest in S that is closest to X by setting  
           SclosestX = SprojectionX.
This makes it automatic that
            X - SclosestX  = X - Sprojection.X 
is in (S^⊥).
When you rearrange this you get
             X = XS + XperpS.
with XS = SclosestX and XperpS .

What does this tell you about S + (S^⊥)?
How does this reveal that the dimension of 
             (S^⊥)= k - dimension of S?

G.12.c)  NullSpace[A] and  RowSpace[A]

Here is a random matrix A hitting on 8D and hanging its hits in 5D:

A  =  
        Table[Random[Real, {-4, 4}], {i, 1, 5}, {j, 1, 
            8}];
MatrixForm[A]

An SVD aligner frame for A is:

SingularValues[A][[3]]

This perpendicular frame is an orthonormal basis for a subspace of 8D which folks call the row space of A..
An orthonormal basis for the nullspace of A is:

NullSpace[A]

Go to the Tutorials and find the relationship between the row space of A and the null space of A.