Home » C Program to Solve Linear Equations using Gauss Elimination Method

C Program to Solve Linear Equations using Gauss Elimination Method

The linear equations in a matrix form are A .X = B and we want to find the values of X. You can solve it in many ways, and one of the simplest ways to solve A.X = B system of equations is Gauss elimination method. It is also known as Reduction method.

This example program solves any kind of linear equation of matrix form using Gauss elimination method.

Problem Definition

This program asks users to input the number of equations in the system of linear equations. The system of the equation looks like the following if the number of an equation is 3.

Example,

```$x_1 + x_2 + x_3 = 2$

$2x_1 - 3x_2 + 2x_3 = -6$

$x_1 + x_2 - 3x_3 = 6$```

The same system of equation in A . X = B form will be

`1112-3211-3 * x1x2x3 = 2-66`

You want to find the solution to x1, x2 and x3 using the Gauss elimination method. The Gauss elimination method is done using a series of row and column operations on the coefficient matrix . The coefficient matrix must be a square matrix otherwise the equation will not work.

For example, if we perform a series of row operation on the above matrix.