Chapter 10. Solving Systems of Linear Equations

Among the least fond memories of high school algebra are the lessons on solving systems of linear equations, with the drudgery of the repetitious hand calculations. This must be one of the algorithms we would most want to implement on a computer.

In this chapter, we'll first review the algorithm behind the hand calculations, and then we'll make some improvements to this algorithm. Finally, we'll implement this algorithm as a Java class that uses matrices.

The Gaussian Elimination Algorithm

Let's start with the following example of a system of four linear equations in four unknowns x1, x2, x3, and x4:

The correct solution is x1 = 1, x2 = −2, x3 = 3, and x4 = −1.

The first set of operations is called

Get Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.