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])={5,-2,9};(Subscript[w, 2])={-3,7,1};

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

v={4,8,-15};

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, 2])",{5,-2,10}],Text["(Subscript[w, 2])",{-3,7,2}],Text["Proj",{-2,2.5,-5}],Text["v",{4,5,-10}],Text["v-Proj",{0,5,-14}]}];

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

N[Norm[v-ProjvontoS]]

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