Maple homework - section 4.2
Key
> restart:with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
First, I enter the vectors:
>
A1:=vector(5,[1,2,4,-5,2]);
A2:=vector(5,[3,2,4,-5,2]);
A3:=vector(5,[5,4,4,-5,-2]);
A4:=vector(5,[1,0,4,2,0]);
Maple 1:
We put the vectors in as columns and row reduce:
> M:=augment(A1,A2,A3,A4);
> gaussjord(M);
Therefore the vectors are all linearly independent and therefore form a basis for a subspace.
>
Maple 2)
> Q1:=evalm(A1);
We first project A2 to Q1:
> prA2:= evalm(dotprod(A2,Q1)/dotprod(Q1,Q1) *Q1);
Now, we compute Q2:
> Q2:= evalm(A2-prA2);
Now, we project A3 to the span of Q1 and Q2
> prA3:= evalm(dotprod(A3,Q1)/dotprod(Q1,Q1) *Q1 + dotprod(A3,Q2)/dotprod(Q2,Q2) *Q2);
Now we compute Q3:
> Q3:= evalm(A3-prA3);
Now we project A4 to the span of Q1,Q2,Q3:
> prA4:= evalm(dotprod(A4,Q1)/dotprod(Q1,Q1) *Q1 + dotprod(A4,Q2)/dotprod(Q2,Q2) *Q2 + dotprod(A4,Q3)/dotprod(Q3,Q3) *Q3 );
and finally we compute Q4:
> Q4:= evalm(A4-prA4);
Lets double check:
> dotprod(Q1,Q2); dotprod(Q1,Q3); dotprod(Q1,Q4); dotprod(Q2,Q3); dotprod(Q2,Q4); dotprod(Q3,Q4);
therefore, the set is orthogonal
>
Our orthogonal basis:
> evalm(Q1); evalm(Q2); evalm(Q3); evalm(Q4);
>
Maple 3:
>
N1:=evalm(Q1/ sqrt(dotprod(Q1,Q1)));
N2:=evalm(Q2/ sqrt(dotprod(Q2,Q2)));
N3:=evalm(Q3/ sqrt(dotprod(Q3,Q3)));
N4:=evalm(Q4/ sqrt(dotprod(Q4,Q4)));
>
Maple 4:
Part a)
> v:= evalm(2*A1-3*A2+4*A3-5*A4);
part b) this has already been done for us (I essentially gave this to you in A-coordinates):
> vA:=vector(4,[2,-3,4,-5]);
Part c) we can compute the coordinates by taking dot products or solving equations:
>
> vQ:=vector(4, [ dotprod(v,Q1)/dotprod(Q1,Q1), dotprod(v,Q2)/dotprod(Q2,Q2), dotprod(v,Q3)/dotprod(Q3,Q3), dotprod(v,Q4)/dotprod(Q4,Q4)]);
lets double check using equations. We want to solve aQ1+bQ2+cQ3+dQ4 = v:
> MQ:= augment(Q1,Q2,Q3,Q4,v): gaussjord(MQ);
Part d) same as above, but this time we know that, for example, dotprod(N1,N1)=1 so we don't have to compute these:
> vN:=vector(4, [ dotprod(v,N1), dotprod(v,N2), dotprod(v,N3), dotprod(v,N4)]);
or, we can solve equations:
> MN:=augment(N1,N2,N3,N4,v): gaussjord(MN);
>
part e)
> sqrt(dotprod(v,v)); sqrt(dotprod(vA,vA)); sqrt(dotprod(vQ,vQ)); sqrt(dotprod(vN,vN));
Notice how the norm of v and vN are the same!
>
>
Maple 5:
To do this, remember that change of coordinates is a linear transformation. So, our matrix should have columns equal to the N coordinates of the vectors A1=[1,0,0,0] (this is a vector in A-coordinates) A2=[0,1,0,0] (also a vector in A coordinate) A3=[0,0,1,0] and A4=[0,0,0,1] (all in A coordinates).
>
Part a)
> A1Q:= vector(4, [dotprod(A1,Q1)/dotprod(Q1,Q1), dotprod(A1,Q2)/dotprod(Q2,Q2), dotprod(A1,Q3)/dotprod(Q3,Q3), dotprod(A1,Q4)/dotprod(Q4,Q4)]);
> A2Q:= vector(4, [dotprod(A2,Q1)/dotprod(Q1,Q1), dotprod(A2,Q2)/dotprod(Q2,Q2), dotprod(A2,Q3)/dotprod(Q3,Q3), dotprod(A2,Q4)/dotprod(Q4,Q4)]);
> A3Q:= vector(4, [dotprod(A3,Q1)/dotprod(Q1,Q1), dotprod(A3,Q2)/dotprod(Q2,Q2), dotprod(A3,Q3)/dotprod(Q3,Q3), dotprod(A3,Q4)/dotprod(Q4,Q4)]);
> A4Q:= vector(4, [dotprod(A4,Q1)/dotprod(Q1,Q1), dotprod(A4,Q2)/dotprod(Q2,Q2), dotprod(A4,Q3)/dotprod(Q3,Q3), dotprod(A4,Q4)/dotprod(Q4,Q4)]);
Here is our change of basis matrix:
> AQ:= augment(A1Q, A2Q, A3Q, A4Q);
Part b)
> evalm(AQ &* vA);
this verifies it because we multiplied a vector in A-coordinates by AQ and got the Q-coordinates of the vector.