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]);

A1 := vector([1, 2, 4, -5, 2])

A2 := vector([3, 2, 4, -5, 2])

A3 := vector([5, 4, 4, -5, -2])

A4 := vector([1, 0, 4, 2, 0])

Maple 1:

We put the vectors in as columns and row reduce:

> M:=augment(A1,A2,A3,A4);

M := matrix([[1, 3, 5, 1], [2, 2, 4, 0], [4, 4, 4, ...

> gaussjord(M);

matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [...

Therefore the vectors are all linearly independent and therefore form a basis for a subspace.

>

Maple 2)

> Q1:=evalm(A1);

Q1 := vector([1, 2, 4, -5, 2])

We first project A2 to Q1:

> prA2:= evalm(dotprod(A2,Q1)/dotprod(Q1,Q1) *Q1);

prA2 := vector([26/25, 52/25, 104/25, -26/5, 52/25]...

Now, we compute Q2:

> Q2:= evalm(A2-prA2);

Q2 := vector([49/25, -2/25, -4/25, 1/5, -2/25])

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);

prA3 := vector([5, 90/49, 180/49, -225/49, 90/49])

Now we compute Q3:

> Q3:= evalm(A3-prA3);

Q3 := vector([0, 106/49, 16/49, -20/49, -188/49])

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 );

prA4 := vector([1, 72/241, 120/241, -150/241, 36/24...

and finally we compute Q4:

> Q4:= evalm(A4-prA4);

Q4 := vector([0, -72/241, 844/241, 632/241, -36/241...

Lets double check:

> dotprod(Q1,Q2); dotprod(Q1,Q3); dotprod(Q1,Q4); dotprod(Q2,Q3); dotprod(Q2,Q4); dotprod(Q3,Q4);

0

0

0

0

0

0

therefore, the set is orthogonal

>

Our orthogonal basis:

> evalm(Q1); evalm(Q2); evalm(Q3); evalm(Q4);

vector([1, 2, 4, -5, 2])

vector([49/25, -2/25, -4/25, 1/5, -2/25])

vector([0, 106/49, 16/49, -20/49, -188/49])

vector([0, -72/241, 844/241, 632/241, -36/241])

>

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)));

N1 := vector([1/10*sqrt(2), 1/5*sqrt(2), 2/5*sqrt(2...

N2 := vector([7/10*sqrt(2), -1/35*sqrt(2), -2/35*sq...

N3 := vector([0, 53/1687*sqrt(241), 8/1687*sqrt(241...

N4 := vector([0, -9/34945*sqrt(69890), 211/69890*sq...

>

Maple 4:

Part a)

> v:= evalm(2*A1-3*A2+4*A3-5*A4);

v := vector([8, 14, -8, -25, -10])

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]);

vA := vector([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)]);

vQ := vector([109/50, 291/98, 934/241, -5])

lets double check using equations. We want to solve aQ1+bQ2+cQ3+dQ4 = v:

> MQ:= augment(Q1,Q2,Q3,Q4,v): gaussjord(MQ);

matrix([[1, 0, 0, 0, 109/50], [0, 1, 0, 0, 291/98],...

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)]);

vN := vector([109/10*sqrt(2), 291/70*sqrt(2), 1868/...

or, we can solve equations:

> MN:=augment(N1,N2,N3,N4,v): gaussjord(MN);

matrix([[1, 0, 0, 0, 109/10*sqrt(2)], [0, 1, 0, 0, ...

>

part e)

> sqrt(dotprod(v,v)); sqrt(dotprod(vA,vA)); sqrt(dotprod(vQ,vQ)); sqrt(dotprod(vN,vN));

sqrt(1049)

3*sqrt(6)

1/142298450*sqrt(1085121811396883766)

sqrt(1049)

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)]);

A1Q := vector([1, 0, 0, 0])

> 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)]);

A2Q := vector([26/25, 1, 0, 0])

> 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)]);

A3Q := vector([1, 100/49, 1, 0])

> 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)]);

A4Q := vector([7/50, 43/98, 6/241, 1])

Here is our change of basis matrix:

> AQ:= augment(A1Q, A2Q, A3Q, A4Q);

AQ := matrix([[1, 26/25, 1, 7/50], [0, 1, 100/49, 4...

Part b)

> evalm(AQ &* vA);

vector([109/50, 291/98, 934/241, -5])

this verifies it because we multiplied a vector in A-coordinates by AQ and got the Q-coordinates of the vector.