Tutorials › Linear Algebra › Maintaining Exact Arithmetic While Solving Ax=b

Vectors and Linear Combinations · Tutorial 133 of 1000

Maintaining Exact Arithmetic While Solving Ax=b

Use fractions throughout row reduction to preserve exact pivots, determine consistency correctly, and verify the resulting solution.

Beginner 9 min read

What You'll Learn

  • Keep rational entries exact during augmented-matrix row reduction.
  • Use nonzero fractions as pivots, however small they are.
  • Explain why elementary row operations preserve the solution set.
  • Recognize an exact row that proves a system inconsistent.
  • Check a computed solution in the original equations.

Why Exact Arithmetic Matters

When a system has integer or fractional coefficients, row reduction can create fractions even if none appeared in the original equations. Rounding those fractions may seem harmless, but a rounded entry can turn a nonzero pivot into zero, or conceal a contradiction in the last row. Either error changes the conclusion about the system: it may appear to have fewer pivots than it really does, or to be consistent when it is not.

For this tutorial, assume the entries of the coefficient matrix \(\mathbf{A}\) and right-hand side \(\mathbf{b}\) are rational numbers. Write each rational number as a fraction and retain it exactly during the calculation. In particular, do not replace a fraction by a rounded decimal partway through row reduction. A finite decimal can represent an exact rational number if it is specified as exact; the danger is rounding an exact value and then treating the rounded value as though it were unchanged.

Definition: The augmented matrix of \(\mathbf{A}\mathbf{x}=\mathbf{b}\) is \(\begin{bmatrix}\mathbf{A}&\mathbf{b}\end{bmatrix}\), formed by adjoining \(\mathbf{b}\) as the last column of \(\mathbf{A}\). Exact row reduction means applying elementary row operations to this matrix while keeping every entry exact, including fractions.

The three elementary row operations are swapping two rows, multiplying a row by a nonzero scalar, and adding a scalar multiple of one row to another. The goal is not to avoid fractions; it is to calculate them correctly. A pivot is an entry used to eliminate entries in its column. With exact arithmetic, a pivot is zero precisely when its numerator is zero after the fraction is simplified. A small nonzero fraction is still a valid pivot.

Why Exact Row Operations Preserve the Answers

Theorem: If \(\mathbf{A}\) and \(\mathbf{b}\) have rational entries, applying elementary row operations to \(\begin{bmatrix}\mathbf{A}&\mathbf{b}\end{bmatrix}\) using exact arithmetic preserves exactly the same solution vectors of \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Proof. Each row of an augmented matrix represents an equation in the unknown entries of \(\mathbf{x}\). Swapping two rows only changes the order of two equations. Multiplying a row by a nonzero scalar replaces an equation by an equivalent equation, because we can divide by that same scalar to recover the original. Adding a multiple of one row to another also preserves equivalence: subtracting that multiple reverses the operation. Therefore each elementary row operation preserves the set of vectors satisfying all the equations. A finite sequence of such operations preserves the same set at every step. Finally, exact addition, subtraction, multiplication, and division by a nonzero rational number produce rational numbers, so carrying out these operations without rounding retains the actual entries at each step. \(\square\)

This theorem explains why exactness matters to the method. Row reduction makes equivalent equations; rounding an entry is not one of the elementary row operations. It can replace the current system with a different one. In the calculations below, each row-operation chain therefore uses fractions rather than rounded approximations.

Worked Example: A Unique Solution with Fractions

Solve \(3x+y=1\), \(x+2y=0\) by exact row reduction. The augmented matrix is

$$ \begin{bmatrix} 3&1&1\\ 1&2&0 \end{bmatrix} \sim \begin{bmatrix} 1&2&0\\ 3&1&1 \end{bmatrix} \sim \begin{bmatrix} 1&2&0\\ 0&-5&1 \end{bmatrix}. $$

The first step swaps \(R_1\) and \(R_2\); the second applies \(R_2\to R_2-3R_1\). Now scale the second row by \(-\tfrac15\), then apply \(R_1\to R_1-2R_2\):

$$ \begin{bmatrix} 1&2&0\\ 0&-5&1 \end{bmatrix} \sim \begin{bmatrix} 1&2&0\\ 0&1&-\tfrac15 \end{bmatrix} \sim \begin{bmatrix} 1&0&\tfrac25\\ 0&1&-\tfrac15 \end{bmatrix}. $$

The rows give \(x=\tfrac25\) and \(y=-\tfrac15\). Check in the original equations: \(3(\tfrac25)-\tfrac15=\tfrac65-\tfrac15=1\), and \(\tfrac25+2(-\tfrac15)=\tfrac25-\tfrac25=0\). Both equations hold.

Exact Pivots and Consistency

After row reduction, a row with zeros in all coefficient columns but a nonzero right-hand side represents an equation of the form \(0=c\), where \(c\ne0\). Such an equation cannot be satisfied, so the system is inconsistent. Conversely, if a row-reduced augmented matrix contains no such row, the reduced equations do not include a contradiction; solving them by assigning values to any free variables gives solutions. This is why exact zero tests in the augmented matrix matter.

Proposition: For a row-reduced augmented matrix, the system is inconsistent if and only if some row has the form \(\begin{bmatrix}0&\cdots&0&|&c\end{bmatrix}\) with \(c\ne0\).

Proof. If such a row occurs, its equation is \(0=c\) with \(c\ne0\), which no vector of unknowns can satisfy. Thus the system is inconsistent. For the converse, suppose no such row occurs. Every nonzero row then has a nonzero coefficient somewhere, and every all-zero coefficient row has right-hand side zero. Assign arbitrary values to the variables in columns without pivots. Starting with the last pivot row and proceeding upward, solve each pivot equation for its pivot variable: its coefficient is nonzero, and the variables to its right already have assigned values. Rows with all coefficients zero impose only \(0=0\). These assignments satisfy every row, so the reduced system has a solution. Since row operations preserve the solution set, the original system is consistent. \(\square\)

Worked Example: A Small Pivot That Must Not Be Rounded Away

Solve the system with augmented matrix \(\begin{bmatrix}1&1&2\\1&\tfrac{1001}{1000}&\tfrac{2001}{1000}\end{bmatrix}\). Subtract \(R_1\) from \(R_2\):

$$ \begin{bmatrix} 1&1&2\\ 1&\tfrac{1001}{1000}&\tfrac{2001}{1000} \end{bmatrix} \sim \begin{bmatrix} 1&1&2\\ 0&\tfrac{1}{1000}&\tfrac{1}{1000} \end{bmatrix}. $$

The entry \(\tfrac{1}{1000}\) is small, but it is not zero. Scale \(R_2\) by \(1000\), then subtract the new \(R_2\) from \(R_1\):

$$ \begin{bmatrix} 1&1&2\\ 0&\tfrac{1}{1000}&\tfrac{1}{1000} \end{bmatrix} \sim \begin{bmatrix} 1&1&2\\ 0&1&1 \end{bmatrix} \sim \begin{bmatrix} 1&0&1\\ 0&1&1 \end{bmatrix}. $$

Therefore \(x=1\), \(y=1\). In the original equations, \(1+1=2\), and \(1+\tfrac{1001}{1000}=\tfrac{2001}{1000}\), so both equations are satisfied.

Here is the error caused by rounding: to two decimal places, \(\tfrac{1001}{1000}\) becomes \(1.00\), and \(\tfrac{2001}{1000}\) becomes \(2.00\). If those rounded values replace the exact ones before elimination, the second row appears to be a copy of the first, suggesting a free variable. But the exact calculation has a second pivot and gives a unique solution. Rounding changed the system and its conclusion.

Worked Example: An Exact Contradiction

Determine whether the system with augmented matrix \(\begin{bmatrix}1&1&2\\2&2&5\end{bmatrix}\) is consistent. Apply \(R_2\to R_2-2R_1\):

$$ \begin{bmatrix} 1&1&2\\ 2&2&5 \end{bmatrix} \sim \begin{bmatrix} 1&1&2\\ 0&0&1 \end{bmatrix}. $$

The last row says \(0=1\), so there is no solution. The contradiction is also visible in the original equations: the first equation says \(x+y=2\), which forces \(2x+2y=4\), while the second requires \(2x+2y=5\). No pair \((x,y)\) can meet both requirements.

A Reliable Exact-Arithmetic Routine

When the entries are rational, a careful workflow keeps each operation auditable and prevents rounding from influencing the answer.

1
Write the augmented matrix.
Copy the coefficients and right-hand side exactly. For example, write \(\tfrac{3}{7}\), not a rounded decimal approximation.
2
Choose a nonzero pivot.
A pivot need not be large. If a column entry is exactly \(\tfrac{1}{1000}\), it is nonzero and may be used; swapping rows can also place a more convenient nonzero entry in the pivot position.
3
Apply and record row operations.
Compute each new entry with exact fractions, simplifying when useful. Do not round intermediate entries.
4
Read the reduced system.
Check for a zero-coefficient row with a nonzero right-hand side. If there is none, solve the pivot equations, retaining exact values.
5
Check the result in the original equations.
Substitute the proposed solution into each original equation, not just into the reduced matrix.

There are two different issues that should not be confused. If the problem gives exact rational data, exact fraction arithmetic determines the answer for that system. If the numbers came from measurements and were only recorded approximately, treating the recorded decimals as exact does not recover the unknown true data; it only solves the system represented by those recorded values. The exact method prevents arithmetic rounding from adding a further, avoidable change.

Common Mistakes

Calling a small fraction zero. In the second worked example, replacing \(\tfrac{1}{1000}\) by \(0\) makes a false free variable and loses the unique solution. The correction is to keep the fraction exact and use it as a pivot, or multiply its row by \(1000\) to obtain a pivot of \(1\).

Rounding each row operation. A fraction created in one step may affect a later pivot or right-hand side. Rounding it immediately can change both. Retain the fraction through the whole reduction; simplify by common factors only when the equality is exact.

Assuming every system has a solution. A row of the form \(\begin{bmatrix}0&0&|&1\end{bmatrix}\) is not a request to choose a variable value. It states the impossible equation \(0=1\). Preserve the right-hand-side entry exactly so that a genuine contradiction is not rounded away.

Exact arithmetic is not a separate method for solving systems. It is a way to carry out the familiar augmented row reduction without silently replacing the system by a nearby one. The distinction is most important when a pivot or a contradiction depends on a small rational value.

Check Your Understanding

Keep all fractions exact, and use the original equations to check any solution you find.

  1. Reduce \(\begin{bmatrix}2&1&1\\1&1&0\end{bmatrix}\) exactly and solve the system.
  2. Why is \(\tfrac{1}{500}\) a valid pivot even though it is less than \(\tfrac{1}{100}\)?
  3. What does the row \(\begin{bmatrix}0&0&|&-\tfrac{3}{7}\end{bmatrix}\) say about consistency?
  4. Describe how rounding \(\tfrac{1001}{1000}\) to \(1.00\) changes the conclusion in the small-pivot example.
  5. Explain why each elementary row operation preserves the solution set, while rounding an entry is not guaranteed to do so.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon