In this chapter we have shown how to use elementary row operations to solve systems of linear equations. We have assumed that each linear equation in the system has the form where the s and the s are real numbers. For simplicity, in our examples we have only chosen equations with integer coefficients — such as:

Systems with Nonrational Coefficients

In fact, a more general choice of coefficients for a system of two equations might have been

Suppose that we solve (??) by elementary row operations. In matrix form we have the augmented matrix Proceed with the following elementary row operations. Divide the row by to obtain Next, subtract times the row from the row to obtain: Then divide the row by , obtaining: Finally, multiply the row by and subtract it from the row to obtain: So

which is both hideous to look at and quite uninformative. It is, however, correct.

Both and are real numbers — they had to be because all of the manipulations involved addition, subtraction, multiplication, and division of real numbers — which yield real numbers.

If we wanted to use MATLAB to perform these calculations, we have to convert , , and to their decimal equivalents — at least up to a certain decimal place accuracy. This introduces errors — which for the moment we assume are small.

To enter and in MATLAB , type

                                                                  

                                                                  
A = [sqrt(2) 2*pi; 3 36.2];
 
b = [22.4; exp(1)];

Now type A to obtain:
A =
 
    1.4142    6.2832  
    3.0000   36.2000

As its default display, MATLAB displays real numbers to four decimal place accuracy. Similarly, type b to obtain
b =
 
   22.4000  
    2.7183

Next use MATLAB to solve this system by typing:

A\b

to obtain
ans =
 
   24.5417  
   -1.9588

The reader may check that this answer agrees with the answer in (??) to MATLAB output accuracy by typing

x1 = 11.2*sqrt(2)-pi*sqrt(2)*(exp(1)-33.6*sqrt(2))/(36.2-3*pi*sqrt(2))
 
x2 = (exp(1)-33.6*sqrt(2))/(36.2-3*pi*sqrt(2))

to obtain
x1 =
 
   24.5417

and
x2 =
 
   -1.9588

More Accuracy

MATLAB can display numbers in machine precision (15 digits) rather than the standard four decimal place accuracy. To change to this display, type

format long

Now solve the system of equations (??) again by typing
A\b

and obtaining
ans =
 
  24.54169560069650  
  -1.95875151860858

Integers and Rational Numbers

Now suppose that all of the coefficients in a system of linear equations are integers. When we add, subtract or multiply integers — we get integers. In general, however, when we divide an integer by an integer we get a rational number rather than an integer. Indeed, since elementary row operations involve only the operations of addition, subtraction, multiplication and division, we see that if we perform elementary row operations on a matrix with integer entries, we will end up with a matrix with rational numbers as entries.

MATLAB can display calculations using rational numbers rather than decimal numbers. To display calculations using only rational numbers, type

format rational

For example, let

To verify these statements, calculate

and

Exercises

Solve the system of equations Check your answer using MATLAB.

Solve the systems of linear equations given in Exercises ?? – ?? and verify that the answers are rational numbers.

.
.

In Exercises ?? – ?? use MATLAB to solve the given system of linear equations to four significant decimal places.

Hint: When entering in MATLAB you must type sqrt(2)*i, even though when you enter , you can just type 2i.