MGM.08 Subspaces, Spans , Dimension, Linear Independence, Basis, Orthonormal Bases
 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].";

Needs["Statistics`ContinuousDistributions`"];

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

Fire from the hip: 
Agree, disagree or fill the blank

L.1)

You are given a spanning set for a subspace S1 of kD and you are given a spanning set for a subspace S2 of kD.
Saying that S1 = S2 is the same as saying that the two spanning sets are identical.
Agree................Disagree............

L.2)

Given a subspace S of 5D, it is automatic that if  X and Y are in S then X + Y is also in S.
Agree............... Disagree............

L.3)

Given a subspace S of 5D, it is automatic that if  X is in S  and t is any real number, then t X is also in S.
Agree................Disagree............

L.4)

The vector {0,0,0,0,0} is in every subspace of 5D.
Agree................Disagree............

L.5)

A subspace S of 5D is defined by:

Clear[i, spanner];
spanner[1] = {2.5, -1.8, -0.7, -3.8, 0.7};
spanner[2] = {0.5, -0.4, 2.8, 3.4, 1.7};
spanner[3] = {-5.1, -2. , 0.2, -2.1, 0.0};
spanner[
          4] = {-3.1, -3.4, -3.3, -9.3, -1.0};
spanners = Table[spanner[i], {i, 1, 4}]

The corresponding SpannerMatrix is:

SpannerMatrix  =  Transpose[spanners];
MatrixForm[SpannerMatrix]

The vertical columns of SpannerMatrix form a spanning set for S.
Agree................Disagree.............

L.6)

Stay with the same subspace S of 5D as defined in L.5) immediately above.
The Sprojection matrix for S is:

rank =  
        Length[SingularValues[SpannerMatrix][[2]]];
Sdim =  rank;
Clear[Sperpframe, k];
Sperpframe[
        k_]  :=  SingularValues[
            SpannerMatrix][[1]][[k]]
aligner  =  Table[Sperpframe[k], {k, 1, Sdim}];
hanger  =   Transpose[aligner];
Sprojection  =  hanger . aligner;
MatrixForm[Sprojection]

The vertical columns of the Sprojection matrix also form a spanning set for S.
Agree................Disagree............

L.7)

Stay with the same subspace S of 5D as defined in part i) immediately above.
The hanger frame for SpannerMatrix is

rank =  
        Length[SingularValues[SpannerMatrix][[2]]];
Sdim =  rank;
Clear[Sperpframe, k];
Sperpframe[
        k_]  :=  SingularValues[
            SpannerMatrix][[1]][[k]]
ColumnForm[Table[Sperpframe[k], {k, 1, Sdim}]]

These three vectors (which are guaranteed to form a perpendicular frame) matrix form an orthonormal basis for S.
Agree................Disagree............

L.8)

Stay with the same subspace S of 5D as defined in part i) immediately above.
Take another look at the hanger frame for the SpannerMatrix:

rank =  
        Length[SingularValues[SpannerMatrix][[2]]];
Sdim =  rank;
Clear[Sperpframe, k];
Sperpframe[
        k_]  :=  SingularValues[
            SpannerMatrix][[1]][[k]]
ColumnForm[Table[Sperpframe[k], {k, 1, Sdim}]]

The fact that the hanger frame for the SpannerMatrix consists of three vectors signals that the dimension of S is 3.
Agree................Disagree............

L.9)

You are given a set of three 2D vectors X1, X2 and X3. 
It is possible that
           {X1, X2, X3} 
turns out to be a linearly independent set.
Agree................
Disagree............

L.10)

You are dealing with a subspace S of 9D and find that the dimension of S is 9.
This allows for the possibility that S is not all of 9D.
Agree................Disagree............

L.11)

Given a matrix A that hits on 3D and hangs in 5D,
The column space of A, R[A], consists of all possible hits with A.
The set of horizontal row vectors of A gives you a spanning set for R[A].
Agree................Disagree............

L.12)

Given a matrix A that hits on 4D and hangs in 2D,
The row space of A, R[(A^t)], consists of all possible hits with (A^t). 
The set of horizontal row vectors of A gives you a spanning set for R[(A^t)] 
Agree................Disagree............

L.13)

Given any matrix A, the dimension of the row space of A is the same as the dimension of the column space of A.
Agree................Disagree............

L.14)

Given any matrix A, then the columns of A form a basis of the column space of A.
Agree................Disagree............

L.15)

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

Clear[s, i, spanner];
spanner[1] = {3.43, -2.57, 
          0.19, -3.94, -2.78};
spanner[2] = {0.97, 1.29, 0.83, 5.23, 0.0};
spanner[3] = {-0.14, 1.08, 0.0, 0.0, -1.45};
spanner[4] = {0.0, 1.0, -1.10, 0.89, 1.51};
spanners = Table[spanner[i], {i, 1, 4}]

The dimension of S is:

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

This is enough information for you to be sure that the set
          {spanner[1], spanner[2], spanner[3], spanner[4]} 
is linearly independent.
Agree................
Disagree............

L.16)

You have a spanning set {spanner[1], spanner[2], spanner[3], spanner[4]} for a subspace S of 6D.

The dimension of the subspace S12 of 6D spanned by {spanner[1], spanner[2]} turns out to be 2.

The dimension of the subspace S123 of 6D spanned by {spanner[1], spanner[2], spanner[3]} turns out to be 2.
The dimension of the subspace S1234 of 6D spanned by {spanner[1], spanner[2], spanner[3], spanner[4]} turns out to be 3.

This is enough to tell you that {spanner[1], spanner[2], spanner[3], spanner[4]} is not a basis for S.

L.17)

You have a spanning set {spanner[1], spanner[2], spanner[3], spanner[4]} for a subpsace S of 6D.

The dimension of the subspace S12 of 6D spanned by {spanner[1], spanner[2]} turns out to be 2.

The dimension of the subspace S123 of 6D spanned by {spanner[1], spanner[2], spanner[3]} turns out to be 3.

The dimension of the subspace S1234 of 6D spanned by {spanner[1], spanner[2], spanner[3], spanner[4]} turns out to be 4.

This is enough to tell you that {spanner[1], spanner[2], spanner[4]} is  a basis for S .

L.18)

You have a spanning set {spanner[1], spanner[2], spanner[3], spanner[4]} for a subpsace S of 6D.

The dimension of the subspace S12 of 6D spanned by {spanner[1], spanner[2]} turns out to be 2.

The dimension of the subspace S123 of 6D spanned by {spanner[1], spanner[2], spanner[3]} turns out to be 3.

The dimension of the subspace S1234 of 6D spanned by {spanner[1], spanner[2], spanner[3], spanner[4]} turns out to be 4.

This is enough to tell you that {spanner[1], spanner[2], spanner[3], spanner[4]} is  an orthonormal basis for S .

L.19)

You have a spanning set {spanner[1], spanner[2], spanner[3], spanner[4]} for a subpsace S of 6D.

The dimension of the subspace S12 of 6D spanned by {spanner[1], spanner[2]} turns out to be 2.

The dimension of the subspace S123 of 6D spanned by {spanner[1], spanner[2], spanner[3]} turns out to be 2.

The dimension of the subspace S1234 of 6D spanned by {spanner[1], spanner[2], spanner[3], spanner[4]} turns out to be 3.

This is enough to tell you that spanner[3] can be written in the form
             spanner[3] = x[1] spanner[1] + x[2] spanner[2] 
for the right choice of numbers x[1] and x[2].

L.20)

A basis of a subspace S of kD is a linearly independent spanning set for S.
Agree................
Disagree............

L.21)

Any perpendicular frame is an orthonormal basis of the subspace it spans.
Agree................
Disagree............

L.22)

Inside every spanning set for a subspace S of kD is a basis of S.
Agree................
Disagree............

L.23)

You are given spanning set for a subspace S of 6D. If this spanning set consists of 6 linearly independent vectors, then it is automatic that S is all of 6D and that the given spanning set is a basis for 6D
Agree................
Disagree............

L.24)

Given a matrix A, you can be sure that the dimension of the column space of A is the same as the rank of A.
Agree................
Disagree............

L.25)

Agree or disagree:
You take the spanning set and make the Spanner Matrix and you calculate Null[SpannerMatrix]. 

If  Null[SpannerMatrix] consists of nothing other than the vector of all zeroes, then the given spanning set is guaranteed to be linearly independent. 

If Null[SpannerMatrix] contains vectors other than the vector of all zeroes, then the given spanning set is guaranteed not to be linearly independent. 
Agree................
Disagree............

L.26)

If {X[1],X[2],X[3],. . .,X[k]} is an orthonormal basis of a k dimensional subspace S of nD, then given any Y in nD the vector in S closest to Y is
             (∑_(j = 1)^k)(Y . X[j]) X[j].
Agree................
Disagree............

L.27)

You are given a subspace S of 13D and a vector X in 13D. 
If ||Sprojection.X|| = ||X||, then Sprojection.X = X and so X is in S.
Agree................
Disagree............