Assignnment 1
Assignnment 1
### problem 7 a)
%display latex
[4 4 4 4]
[4 4 4 4]
[4 4 4 4]
# Or we could utilize
Sa= ones_matrix(3,4)*4
Sa
[4 4 4 4]
[4 4 4 4]
[4 4 4 4]
[1 1 1 1]
[0 0 0 0]
[0 0 0 0]
[1 2 3 4]
[2 3 4 5]
[3 4 5 6]
Sb.rref()
[ 1 0 -1 -2]
[ 0 1 2 3]
[ 0 0 0 0]
Sc.rref()
[ 1 -1 1 -1]
[ 0 0 0 0]
[ 0 0 0 0]
### Problem 8
# p+2q+3r+s = 1
# 2p+q+8r+2s= 2
# p+6q-3r+5s= -2
# 2p-q+r-s= λ with λ= 0 for a,b,c
# a) solve directly
p,q,r,s =SR.var('p,q,r,s')
[ 1 2 3 1]
[ 2 1 8 2]
[ 1 6 -3 5]
[ 2 -1 1 -1]
(1, 2, -2, 0)
A_inv= A.inverse()
A_inv
# we know that A_inv*A*X = A_inv*B with X=matrix([p], [q], [r],
[s])
# or we could use
A**(-1)*B
# we first write the augmented matrix of the system and find its RREF
C= matrix(QQ, [[1,2,3,1],[2,1,8,2],[1,6,-3,5,],[2,-1,1,-1]])
C
[ 1 2 3 1]
[ 2 1 8 2]
[ 1 6 -3 5]
[ 2 -1 1 -1]
CR= C.rref()
CR
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
[ 1 2 3 1| 1]
[ 2 1 8 2| 2]
[ 1 6 -3 5|-2]
[ 2 -1 1 -1| 0]
CBB= CB.rref()
CBB
[ 1 0 0 0|-18/65]
[ 0 1 0 0| 17/65]
[ 0 0 1 0|51/130]
[ 0 0 0 1|-11/26]
# since the first 4 rows are the Identity matrix, the solutions of the
system are row 5
CBB.column(4)
p,q,r,s,λ =SR.var('p,q,r,s,λ')
solve([p+2*q+3*r+s == 1,2*p+q+8*r+2*s == 2,p+6*q-3*r+5*s == -2,2*p-
q+r-s == λ],p,q,r,s,λ)
R3 = R3 − R1
0 1 0 0 1 0 2
A = 0 0 0 1 1 0 −1
0 0 0 0 −1 1 −1
Having finished with the first pivot, we move on to the second and third
rows with the following:
R1 = R1 + R3
R2 = R2 + R3
0 1 0 0 0 1 1
A = 0 0 0 1 0 1 −2
0 0 0 0 1 −1 1
Which is now in RREF format.
For Ax = b we have :
X1
X2
0 1 0 0 0 1
X3 1
0 0 0 1 0 1 ·
= −2
X4
0 0 0 0 1 −1
X5 1
X6
With back substitution we get:
1
X2 + X6 1
X4 + X6 = −2
X5 − X6 1
Since X2 , X4 , X5 are pivots, we can set the free variable as being equal to
a constant:
X6 = c
Therefore our solutions are
X2 = 1 − c
X4 = −2 − c
X5 = 1 + c
2
2 Problem 10
In order to prove that
2
x1 = −1
3
1
x2 = 1
−2
3
x3 = −3
8
Are linearly independent
For that we need:
λ1 · x1 + λ2 · x2 + λ3 · x3 = 0
2 1 3 0
λ1 −1 + λ2 1 + λ3 −3 = 0
3 −2 8 0
Which is the equivalent of
2λ1 λ2 3λ3 0
−λ1 + λ2 + −3λ3 = 0
3λ1 −2λ2 8λ3 0
Which leads us to
2λ1 + λ2 + 3λ3 = 0
−λ1 + λ2 − 3λ3 = 0
3λ1 − 2λ2 + 8λ3 = 0
Out of which we get the new augmented Matrix
2 1 3 0
A = −1 1 −3 0
3 −2 8 0
We will use Gaussian elimination to get the RREF form of the matrix as
such:
R2 = R2 + R1 /2
R3 = R3 − 3R1 /2
With R1 is the first row of the table, R2 is the second row, etc.
3
2 1 3 0
A = 0 3/2 −3/2 0
0 −7/2 7/2 0
Likewise, to find the pivots we proceed with:
R1 = R1 − 2R2 /3
R3 = R3 + 7R2 /3
0 0 4 0
A = 0 3/2 −3/2 0
0 0 0 0
To turn the pivots into 1, we use:
R1 = R1 /2
R2 = 2R2 /3
Finally the RREF matrix will be
1 0 2 0
A = 0 1 −1 0
0 0 0 0
This leans that:
λ1 + 2λ3 = 0
λ2 − λ3 = 0
Therefore, by setting the free variable as λ3 = c, we get:
λ2 = c
λ1 = −2c
Since λ1 , λ2 , λ3 are not zero, we can discern that
2
x1 = −1
3
1
x2 = 1
−2
3
x3 = −3
8
Are not linearly independent.