Gauss Elimination Calculator

Gaussian Elimination Calculator

Solve a 3×3 System of Linear Equations using Row Echelon Form and Back Substitution.

x
y
z
Constant (b)
Eq1
Eq2
Eq3

Solution Results:


Understanding Gaussian Elimination

Gaussian elimination, also known as row reduction, is an algorithm in linear algebra used for solving systems of linear equations. It operates on an augmented matrix where the coefficients of the variables and the constants on the right side of the equations are listed in rows.

The Three Elementary Row Operations

To reach the Row Echelon Form (REF), the calculator performs three types of operations:

  • Swapping: Interchanging two rows if a pivot element is zero.
  • Scaling: Multiplying a row by a non-zero scalar.
  • Pivoting (Addition): Adding a multiple of one row to another row to create zeros beneath the leading coefficient.

A Step-by-Step Example

Consider the following 3×3 system:

2x + 1y – 1z = 8
-3x – 1y + 2z = -11
-2x + 1y + 2z = -3
  1. Forward Elimination: We use the first row to eliminate the 'x' terms in the second and third rows. Then use the second row to eliminate the 'y' term in the third row.
  2. Back Substitution: Once we have a triangular form, we solve for 'z' first, then substitute 'z' back into the second equation to find 'y', and finally substitute both into the first equation to find 'x'.

Applications of Gaussian Elimination

This method is fundamental in various fields, including:

  • Engineering: Solving structural analysis problems and electrical circuit networks.
  • Physics: Determining balancing forces in static equilibrium.
  • Computer Science: Used in 3D graphics and machine learning algorithms for weight optimization.
  • Economics: Input-output models for analyzing industrial dependencies.
function calculateGauss() { var matrix = [ [ parseFloat(document.getElementById('m00').value) || 0, parseFloat(document.getElementById('m01').value) || 0, parseFloat(document.getElementById('m02').value) || 0, parseFloat(document.getElementById('m03').value) || 0 ], [ parseFloat(document.getElementById('m10').value) || 0, parseFloat(document.getElementById('m11').value) || 0, parseFloat(document.getElementById('m12').value) || 0, parseFloat(document.getElementById('m13').value) || 0 ], [ parseFloat(document.getElementById('m20').value) || 0, parseFloat(document.getElementById('m21').value) || 0, parseFloat(document.getElementById('m22').value) || 0, parseFloat(document.getElementById('m23').value) || 0 ] ]; var n = 3; // Forward Elimination for (var i = 0; i < n; i++) { // Partial Pivoting var maxRow = i; for (var k = i + 1; k Math.abs(matrix[maxRow][i])) { maxRow = k; } } var temp = matrix[i]; matrix[i] = matrix[maxRow]; matrix[maxRow] = temp; // Check if singular if (Math.abs(matrix[i][i]) < 1e-10) { document.getElementById('gauss-result-area').style.display = 'block'; document.getElementById('solution-output').innerHTML = 'The system is singular or has no unique solution (division by zero).'; return; } // Zero out below pivot for (var k = i + 1; k < n; k++) { var factor = matrix[k][i] / matrix[i][i]; for (var j = i; j = 0; i–) { var sum = 0; for (var j = i + 1; j < n; j++) { sum += matrix[i][j] * solutions[j]; } solutions[i] = (matrix[i][n] – sum) / matrix[i][i]; } // Display results var resultDiv = document.getElementById('solution-output'); var output = 'Variable values:'; output += 'x = ' + formatNum(solutions[0]) + "; output += 'y = ' + formatNum(solutions[1]) + "; output += 'z = ' + formatNum(solutions[2]); document.getElementById('gauss-result-area').style.display = 'block'; resultDiv.innerHTML = output; } function formatNum(num) { if (Math.abs(num) < 1e-10) return "0"; return Number(num.toFixed(4)).toString(); }

Leave a Comment