Professional Documents
Culture Documents
3x1 − 2x2 = 6
−5x1 + 4x2 = 8,
we let
3 −2 6 6 −2 3 6
A= ,b = , A1 = , and A2 =
−5 4 8 8 4 −5 8
where A1 is matrix from A by replacing the first column by b and A2 is matrix from
A by replacing the second column by b.
By Cramer’s Rule, we obtain
det(A1 ) det(A2 )
x1 = = 20, and x2 = = 27.
det(A) det(A)
x1 − 2x2 + x3 = 0
2x2 − 8x3 = 8
−4x1 + 5x2 + 9x3 = −9
we let
1 −2 1 0 0 −2 1
B= 0 2 −8 , b = 8 , B1 = 8 2 −8 ,
−4 5 9 −9 −9 5 9
1 0 1 1 −2 0
B2 = 0 8 −8 , and B3 = 0 2 8
−4 −9 9 −4 5 −9
where Bi is matrix from B by replacing the column i by b.
By Cramer’s Rule, we obtain
det(B1 ) det(B2 ) det(B3 )
x1 = = 29, x2 = = 16, and x3 = = 3.
det(B) det(B) det(B)
Besides solving system equation, we can use Cramer’s rule to find the inverse matrix of
a given matrix. Here we see an example:
1
2 1 3
• Ex3. Given a matrix C = 1 −1 1. To find the inverse matrix D of C, we need
1 4 −2
find D such that CD = I:
2 1 3 d11 d12 d13 1 0 0
1 −1 1 d21 d22 d23 = 0 1 0 .
1 4 −2 d31 d32 d33 0 0 1
One can see that it is easy to get the determinants of C1 , C2 , C3 because one of the
columns contains two zeros in each Ci where
Then we have
det(C1 ) −2 det(C2 ) 3 det(C3 ) 5
d11 = = , d21 = = , and d31 = =
det(C) 14 det(C) 14 det(C) 14
2
0 1 3
1 14
d12 = 1 −1 1 = = 1,
det(C) 14
0 4 −2
2 0 3
1 −7 −1
d22 = 1 1 1 = = ,
det(C)
14 2
1 0 −2
2 1 0
1 −7 −1
d32 = 1 −1 1 = = .
det(C)
14 2
1 4 0
Solving d3 :
0 1 3
1 4 2
d13 = 0 −1 1 = = ,
det(C)
14 7
1 4 −2
2 0 3
1 1
d23 = 1 0 1 = ,
det(C) 14
1 1 −2
2 1 0
1 −3
d33 = 1 −1 0 = .
det(C)
14
1 4 1
Then we got the inverse matrix D = (d1 , d2 , d3 ):
−1 2
7 1
7
3 −1 1
D= 14
.
2 14
5 −1 −3
14 2 14
We can check it by multiplying D on C directly and see if we can get an idenity.
• In example 1, we have
>> A=[3 −2;−5 4 ] ; b = [ 6 ; 8 ] ;
>> A1=[b ,A ( : , 2 ) ] ; A2=[A( : , 1 ) , b ] ;
3
x
Then we can find x = 1 via
x2
>> x=[ d e t (A1) / de t (A ) ; d et (A2) / d et (A ) ]
x =
20.0000
27.0000
which means x1 = 20, x2 = 27. We also can use command A\b to check the solution of
Ax = b:
>> A\b
ans =
20.0000
27.0000
29
16
3
• In example 3, we have
4
>> C=[2 1 3 ; 1 −1 1 ; 1 4 −2];
>> e1 = [ 1 ; 0 ; 0 ] ; e2 = [ 0 ; 1 ; 0 ] ; e3 = [ 0 ; 0 ; 1 ] ;
We can change the format to see the fractions by using format rat ( and you can use
the command format short or format long to change the number representation
back):
>> format r a t
>> d1=[ d e t (C1) / d e t (C ) ; d e t (C2) / d e t (C ) ; d et (C3) / d et (C ) ]
d1 =
−1/7
3/14
5/14
which are the values we got earlier. Similarly, we can get the other two vectors in D:
>> C1=[ e2 ,C ( : , 2 : 3 ) ] ; C2=[C ( : , 1 ) , e2 ,C ( : , 3 ) ] ; C3=[C ( : , 1 : 2 ) , e2 ] ;
>> d2=[ d e t (C1) / d e t (C ) ; d e t (C2) / d e t (C ) ; d et (C3) / d et (C ) ]
d2 =
1
−1/2
−1/2
and
>> C1=[ e3 ,C ( : , 2 : 3 ) ] ; C2=[C ( : , 1 ) , e3 ,C ( : , 3 ) ] ; C3=[C ( : , 1 : 2 ) , e3 ] ;
>> d3=[ d e t (C1) / d e t (C ) ; d e t (C2) / d e t (C ) ; d et (C3) / d et (C ) ]
d3 =
2/7
1/14
−3/14
Finally, we can use the inversre matrix command inv(C) to check our answer:
5
i n v (C)
ans =
−1/7 1 2/7
3/14 −1/2 1/14
5/14 −1/2 −3/14
6
Exercises
2 1 3 3 0 0
1. Given a matrix C = 1 −1 1 and a matrix E =
0 1 0. Use Cramer’s
1 4 −2 0 0 2
rule to find a matrix D such that CD = E.
2x1 + x2 + x3 = 4
−x1 + 2x3 = 2
3x1 + x2 + 3x3 = −2
3 6 7
3. Given a matrix F = 0 2 1. Use Cramer’s rule to find the inverse matrix of
2 3 4
F.
1 2 4
4. Given a matrix G = 0 −3 1. Use Cramer’s rule to find the inverse matrix of
0 0 3
G.
3 0 0
5. Given a matrix H = −1
1 0. Use Cramer’s rule to find the inverse matrix of
−2 3 2
H.