Math 2270 Sec. 2 MAPLE Assignment #1: Solutions.
> with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
You are to create a document in which you answer the following questions, using a mixture of MAPLE computations and textual insertions (using # to comment or handwritten text.)
Each problem is worth 5 points.
1.a Define
( 2 3 4 ) ( 3 2 1 )
A = ( 5 6 7 ) , B = ( 4 3 2 ) .
( 8 9 0 ) ( 5 4 3 )
Compute AB and BA. Are they the same?
Solution:
> A:= matrix([[ 2 , 3, 4], [5, 6, 7], [8, 9, 0]]);
A :=
2 3 4
5 6 7
8 9 0
> B:= matrix([[3, 2, 1 ], [4 , 3, 2], [5, 4, 3]]);
B :=
3 2 1
4 3 2
5 4 3
> multiply(A,B);
38 29 20
74
60
56
43
38
26
> multiply(B,A);
24 30 26
39
54
48
66
37
48
The products AB and BA are not the same.
1.b. Compute A + B and B + A. Are they the same?
Solution:
> evalm(A+B);
5 5 5
9 9 9
13 13 3
> evalm(B+A);
5 5 5
9 9 9
13 13 3
Therefore A+B and B+A are the same.
1.c . Define C to be A + B. Compute C^2 and compare it to
A^2 + 2AB + B^2.
Are they the same? Can you think of a small change you could make in the
expression A^2 + 2AB + B^2 in order to make it equal to C^2 ?
Solution.
> C:=evalm(A+B);
C :=
5 5 5
9 9 9
13 13 3
> evalm(C^2);
135 135 85
243
221
243
221
153
191
> evalm(A^2+B^2+2*A&*B);
149 134 79
278
227
251
198
154
169
> evalm(A^2+B^2+A&*B + B&*A);
135 135 85
243
221
243
221
153
191
Therefore
> C^2= A^2+B^2+A.B + B.A;
C
2 =
A
2 +
B
2 +
( . )
+
( )
1.d. Compute the transpose of AB and compare it to the product of the transpose of A
and the transpose of B multiplied in the correct order to get equality.
> transpose(A&*B);
38 74 60
29
20
56
38
43
26
> evalm(transpose(A)&*transpose(B));
24 39 54
30
26
48
37
66
48
> evalm(transpose(B)&*transpose(A));
38 74 60
29
20
56
38
43
26
Therefore :
( . )
T = T
( B ) .
T
( A ) e Define v = (1,2,3) to be a vector. Compute Av.
What does MAPLE give you when you try vA?
Solution.
> v:=vector([1, 2, 3]); v := [ ]
> evalm(A&*v);
[ , , ]
> evalm(v&*A);
[ , , ]
Thus while computing vA MAPLE automatically transposes the vector v making it a row vector, instead of a column.
1.f Solve Ax = v in three ways where v is the vector in (1.e): by row reducing
the augmented matrix, by using the command linsolve , and by using the inverse
matrix of A.
Solution.
Solution using RREF:
> augment(A, v);
2 3 4 1
5 6 7 2
8 9 0 3
> J:=rref(%);
J :=
1
0
0
1
0
0
0
1
3
0 0 1 0
> col(J, 4);# The last column of the matrix J is the solution vector.
0
1
, ,
3
0
Solution using linsolve:
> x:=linsolve(A,v); x :=
0
1
, ,
3
0
Solution using the inverse matrix: x=inverse(A)&*v.
> evalm( inverse(A)&* v);
0
1
, ,
3
0
2.a Solve Bx = w where B is as above and w=(1,2,3). Verify that your
solution solves Bx = w.
Solution.
> w:= vector([1,2,3]); w := [ ]
> augment(B, w);
3 2 1 1
4 3 2 2
5 4 3 3
> K:=rref(%);
K :=
1 0 -1 -1
0 1 2 2
0 0 0 0
We this see that the system has infinitely many solutions. We can find them all using linsolve; note that the vector
> col(K, 4);
[ , , ] is only one solution of the system.
> X:=linsolve(B, w);
X := [ _t
1
,
−
2 _t
1
, _t
1
+
1 ]
Hence MAPLE’s solution is: x=t, y=-2t, z=t+1. Let’s check that this solution really works:
> evalm(B&*X);
[ , , ] which is indeed the vector w of the right hand side.
2.b Repeat your work in order to solve Bx = z where z = (1,2,4). Explain
your answer.
Solution.
> z:=vector([1,2,4]); z := [ ]
> Y:=linsolve(B, z);
Y :=
So, MAPLE could not find a solution. Let’s see what is wrong by using RREF:
> rref(augment(B, z));
1 0 -1 0
0 1 2 0
0 0 0 1
Thus the last equation says 0=1, i.e. the system has no solutions. What is happening here is that the vector w is in the image of B, but the vector z is not.
3.a Plot the graph of the line x/2 + 3y=7 on the interval x=2..4 using both plot and implicitplot commands
Solution.
> with(plots):
> solve(x/2+ 3*y=7, y);
−
1
+
6 x
> plot(%, x=2..4); #Ordinary plot
7
3
1.85
1.8
1.75
1.7
2
1.95
1.9
2 2.2
2.4
2.6
2.8
3 x
3.2
3.4
3.6
3.8
The implicitplot is called implict because it does not require you to solve the equation:
> implicitplot(x/2+ 3*y=7, x=2..4, y=0..2);
4
2
1.95
1.9
y
1.85
1.8
1.75
1.7
2 2.5
3 x
3.5
4
3.b. By plotting lines (anyway you like) determine if the system of equations 3x+2y=5, 2x-y=3 has a solution and if the solution is unique
Solution.
> L1:=implicitplot(3*x+2*y=5, x=-1..3, y=-2..2):
> L2:= implicitplot(2*x-y=3, x=-1..3, y=-2..2):
> display({L1,L2});
2 y
1
0
0.5
–1
1 1.5
x
2 2.5
3
–2
Therefore the lines intersect in a single point, which means that the system has unique solution.