Introduction

This method finds all the solutions of a linear equations system. The definition of a linear equations system can be found in this post.

Method

Gauss method works on two parts. The first one, known as forward elimination, transforms a regular matrix into an upper triangular matrix, in the form

This step works in what’s call “pivoting”: taking the leftmost element of each row and doing some operations in order to obtain n zero coefficients.

The second step is known as backward substitution: it starts on the bottom row, which only has one non-zero coefficient, and starts finding values. Then, it uses these values to solve the following equations.

Examples

  • A = [7., 2.; -21., -5.], B = [16.; 50.], R = [-25.7; 98.]
  • A = [2., -3.; 4., 1.], B = [-2.; 24.], R = [5.; 4.]
  • A = [3., -0.1, -0.2; 0.1, 7., -0.3; 0.3, -0.2, 10.], B = [7.85; -19.3; 71.4], R = [3.; -2.5; 7.]
  • A = [0.3, 0.52, 1.; 0.5, 1., 1.9; 0.1, 0.3, 0.5], B = [-0.01; 0.67; -0.44], R=[-14.9; -29.5; -19.8]

Singularities

This method is not an iterative method. Even though it realizes the calculations with iterations, these iterations are defined by the size of the matrix and not by the contents of it. An iterative method realizes unknown iterations, and it stops until it meets an error criteria given. Because of this, an iterative method can diverge. On the other hand, a non-iterative error makes a fixed number of iterations. It can have a terrible complexity, but it is finite. It does not diverge, it does not fail.

Flowchart

Gauss

Code

Conclusions

Gauss is a simple method for solving equations. It requires some computational time that scales with the matrix size, but it is not as hard as Cramer.

Advertisements