5.2. MATLAB AND MATRIX ARITHMETIC 99

This gives the solution as x = A−1b. Note that once you have found the inverse, you caneasily get the solution for different right hand sides without any effort. It is always justA−1b. In the given example, the inverse of the matrix is 0 1

212

1 −1 01 − 1

2 − 12

This was shown in Example 5.1.36. Therefore, from what was just explained, the solutionto the given system is x

yz

=

 0 12

12

1 −1 01 − 1

2 − 12

 1

32

=

52−2− 3

2

 .

What if the right side of 5.21 had been(

0 1 3)T

? What would be the solution to 1 0 11 −1 11 1 −1

 x

yz

=

 013

?

By the above discussion, it is just xyz

=

 0 12

12

1 −1 01 − 1

2 − 12

 0

13

=

 2−1−2

 .

This illustrates why once you have found the inverse of a given matrix, you can use it tosolve many different systems easily.

5.2 MATLAB And Matrix ArithmeticTo find the inverse of a square matrix in matlab, you open it and type the following. The>> will already be there.

>>inv([1,2,3;5,2,7;8,2,1]) Then press enter and it will give the following:ans =-0.1667 0.0556 0.11110.7083 -0.3194 0.1111-0.0833 0.1944 -0.1111Note how it computed the inverse in decimals. If you want the answer in terms of

fractions, you do the following:>>inv(sym([1,2,3;5,2,7;8,2,1])) Then press enter and it will give the following:ans =[ -1/6, 1/18, 1/9][ 17/24, -23/72, 1/9][ -1/12, 7/36, -1/9]You can do other things as well. Say you have