Page 330 #5

The following function performs projection, where A is the matrix whose columns are the basis vectors, and v is the vector to project.

ProjFunction[A_,v_]:= A.Inverse[Transpose[A].A].Transpose[A].v;

w1 = {-1,0,2,1};
w2 = {1,-5,6,1};
w3= {2,1,0,-3};

v = {-2,3,1,2};

(CM = Transpose[{w1,w2,w3}])//MatrixForm

CM.Inverse[Transpose[CM].CM].Transpose[CM].v

ProjFunction[CM,v]

v2 = {3,0,-6,-3};

ProjFunction[CM,v2]

Join[CM,Transpose[{v2}],2]//MatrixForm

RowReduce[Join[CM,Transpose[{v2}],2]]//MatrixForm

Problem 5c on page 330

ww1 = {-1,0,2,1,0};
ww2 = {1,-5,6,1,-1};
ww3 = {2,1,0,-3,-2};

(CM2 = Transpose[{ww1,ww2,ww3}])//MatrixForm

v3 = {2,-4,-8,-1,-3};

ProjFunction[CM2,v3]

v4 = {2,-4,8,-1,2};

ProjFunction[CM2,v4]

Transpose[CM2].CM2//MatrixForm

Moving onto 8.5, problem 1a on Mathematica

w1 = 1/Sqrt[17]*{1,4};
w2 = 1/Sqrt[17]*{-4,1};

CM = Transpose[{w1,w2}];

Transpose[CM].CM//MatrixForm

Problem 6 on Page 339

(Subscript[f, 1]) = 1/Sqrt[2π];
(Subscript[f, 2]) = 1/Sqrt[π]*Cos[x];
(Subscript[f, 3]) = 1/Sqrt[π]*Sin[x];
(Subscript[f, 4]) = 1/Sqrt[π]*Cos[2x];
(Subscript[f, 5]) = 1/Sqrt[π]*Sin[2x];

Integrate[(Subscript[f, 2])*(Subscript[f, 4]),{x,0,2π}]

Integrate[(Subscript[f, 4])*(Subscript[f, 4]),{x,0,2π}]

WM = IdentityMatrix[5]- IdentityMatrix[5];

WM//MatrixForm

For[i=1,i≤ 5,i=i+1,
For[j=1,j≤ 5, j=j+1,
WM[[i,j]] = Integrate[(Subscript[f, i])*(Subscript[f, j]),{x,0,2π}];
];
];

WM//MatrixForm

Problem 7 on page 339

Integrate[1*1,{x,-1,1}]

(Subscript[q, 1]) = 1/Sqrt[2];

Integrate[(Subscript[q, 1])*(Subscript[q, 1]),{x,-1,1}]

x - Integrate[x*(Subscript[q, 1]),{x,-1,1}]*(Subscript[q, 1])

(Subscript[q, 2]) = x/Sqrt[Integrate[x*x,{x,-1,1}]]

Integrate[(Subscript[q, 2])*(Subscript[q, 2]),{x,-1,1}]

Integrate[(Subscript[q, 1])*(Subscript[q, 2]),{x,-1,1}]