Chapter 8 - Independence, Basis, and Dimension for Subspaces of (R^n)

Section 8.4 - Vector Projection onto a Subspace of (R^n)

Example 8.4.1

(Subscript[w, 1])={1,1,0};(Subscript[w, 2])={0,0,1};

(wrow={(Subscript[w, 1]),(Subscript[w, 2])})//MatrixForm

v={-1,2,1};

RowReduce[Join[wrow,{v}]]//MatrixForm

W={{0,0},{0,0}};

For[k=1,k≤2,k=k+1,
For[l=1,l≤2,l=l+1,
W[[k,l]]=(Subscript[w, k]).(Subscript[w, l]);]];

W//MatrixForm

V={{0},{0}};

For[k=1,k≤2,k=k+1,V[[k]]=(Subscript[w, k]).v;];

V//MatrixForm

(A=Inverse[W].V)//MatrixForm

ProjvontoS=Sum[A[[k]] (Subscript[w, k]),{k,1,2}]

N[ProjvontoS-v]

(v-ProjvontoS).(Subscript[w, 1])

(v-ProjvontoS).(Subscript[w, 2])

(CMat=Transpose[wrow])//MatrixForm

CMat.Inverse[Transpose[CMat].CMat].Transpose[CMat].v//MatrixForm

Cp=Cross[(Subscript[w, 1]),(Subscript[w, 2])]

PlaneS=Cp[[1]] x+Cp[[2]] y+Cp[[3]] z==0

PlaneSPlot=ContourPlot3D[Evaluate[PlaneS],{x,-12,12},{y,-12,12},{z,-12,12},Mesh->None,ContourStyle->{Opacity[0.5],LightBlue}];

ArrowPlots=Graphics3D[{PlotPoints->1,Arrowheads[.05],Thickness[0.010],Red,Arrow[{{0,0,0},(Subscript[w, 1])}],Black,Arrow[{{0,0,0},(Subscript[w, 2])}],Blue,Arrow[{{0,0,0},ProjvontoS}],Black,Arrow[{{0,0,0},v}],Yellow,Arrow[{ProjvontoS,v}]}];

TxtPlots=Graphics3D[{Black,Text["(Subscript[w, 1])",{1,1,0}],Text["(Subscript[w, 2])",{0,0,1}],Text["Proj",{0.5,0.5,1}],Text["v",{-1,2,1}],Text["v-Proj",{-1.5,1.5,0}]}];

Show[PlaneSPlot,ArrowPlots,TxtPlots,AxesLabel->{"x","y","z"}, PlotRange->{{-2,2},{-2,2},{-2,2}}]

v-ProjvontoS

N[Norm[v-ProjvontoS]]

Abs[N[Cp.v/Norm[Cp]]]

v1 = {1,0,1};
v2 = {0,1,1};
w1 = {2,-1,1};
w2 = {-1,5,4};

RowReduce[{v1,v2}]//MatrixForm

RowReduce[{v1,v2,w1}]//MatrixForm
RowReduce[{v1,v2,w2}]//MatrixForm

v1 = {2,3,-4,1};
v2 = {-1,2,-1,1};
v3 = {2,1,-1,1};
w1 = {1,3,-2,2};
w2 = {3,6,-6,2};

RowReduce[{v1,v2,v3}]//MatrixForm
RowReduce[{w1,w2}]//MatrixForm

A = {{1,-2,1,8,0,-1},{4,-2,8,3,2,3},{2,1,3,7,8,1},{1,-1,4,-12,-6,3}};

A//MatrixForm

RowReduce[A]//MatrixForm

(SpanningMatrix = Join[Drop[Drop[-RowReduce[A],-1],{},3],IdentityMatrix[3]])//MatrixForm

(V1 = Take[SpanningMatrix, All, {1}])//MatrixForm

(V2 = Take[SpanningMatrix, All, {2}])//MatrixForm

(V3 = Take[SpanningMatrix, All, {3}])//MatrixForm