Gaussian Elimination Calculator

Gaussian Elimination Calculator

Solve 3×3 Systems of Linear Equations

Enter the coefficients for the augmented matrix (Ax = B):

Solution:

Understanding Gaussian Elimination

Gaussian elimination is a fundamental algorithm in linear algebra used to solve systems of linear equations. It transforms a system's augmented matrix into row-echelon form using three types of row operations: swapping rows, multiplying a row by a non-zero constant, and adding/subtracting a multiple of one row to another.

The Three Main Steps

  1. Forward Elimination: We use row operations to create zeros below the main diagonal (pivoting), moving from left to right. This results in an upper triangular matrix.
  2. Row Echelon Check: The algorithm checks if the system is consistent (has a solution) or if it has infinitely many solutions or no solution at all.
  3. Back Substitution: Starting from the bottom row, we solve for each variable (z, then y, then x) by substituting the known values into the equations above.

Example Calculation

Suppose you have the following system:

2x + 1y – 1z = 8
-3x – 1y + 2z = -11
-2x + 1y + 2z = -3

By entering these values (2, 1, -1, 8, etc.) into the calculator above, the algorithm will perform the row reductions to find that x = 2, y = 3, z = -1.

Why Use This Calculator?

Manual Gaussian elimination is prone to arithmetic errors, especially with fractions. This tool provides an instant solution for 3×3 systems, which are common in physics (circuit analysis), economics (input-output models), and engineering (structural stresses).

function solveGaussian() { var matrix = [ [parseFloat(document.getElementById('m00').value), parseFloat(document.getElementById('m01').value), parseFloat(document.getElementById('m02').value), parseFloat(document.getElementById('b0').value)], [parseFloat(document.getElementById('m10').value), parseFloat(document.getElementById('m11').value), parseFloat(document.getElementById('m12').value), parseFloat(document.getElementById('b1').value)], [parseFloat(document.getElementById('m20').value), parseFloat(document.getElementById('m21').value), parseFloat(document.getElementById('m22').value), parseFloat(document.getElementById('b2').value)] ]; var resultDiv = document.getElementById('gauss-result'); var output = document.getElementById('solution-output'); // Validation for (var i = 0; i < 3; i++) { for (var j = 0; j < 4; j++) { if (isNaN(matrix[i][j])) { resultDiv.style.display = 'block'; output.innerHTML = 'Error: Please fill in all fields with valid numbers.'; return; } } } var n = 3; // Forward Elimination for (var i = 0; i < n; i++) { // Pivot selection var maxRow = i; for (var k = i + 1; k Math.abs(matrix[maxRow][i])) { maxRow = k; } } // Swap rows var temp = matrix[i]; matrix[i] = matrix[maxRow]; matrix[maxRow] = temp; // Check for singularity if (Math.abs(matrix[i][i]) < 1e-10) { resultDiv.style.display = 'block'; output.innerHTML = 'The system is singular or has no unique solution (division by zero).'; return; } // Eliminate column 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] * solution[j]; } solution[i] = (matrix[i][n] – sum) / matrix[i][i]; } // Display resultDiv.style.display = 'block'; output.innerHTML = 'x = ' + solution[0].toFixed(4).replace(/\.?0+$/, "") + '' + 'y = ' + solution[1].toFixed(4).replace(/\.?0+$/, "") + '' + 'z = ' + solution[2].toFixed(4).replace(/\.?0+$/, ""); }

Leave a Comment