This code solves n system of linear equations using Naive-Gaussian elimination. The code checks the existence of zeros on the diagonal and replace the rows to make the diagonal zeros-clear, then builds the upper-triangular matrix and solve it. You need just to write the Coefficients Matrix A and the Right-Hand-Side Matrix to start the code. The result compared with the true high accuracy answer.
Naive-Gaussian elimination considered one of the most popular numerical techniques for solving simultaneous linear equations. The approach is designed to solve a set of n equations with n unknowns, [A][X] = [C], where [A]nxn is a square coefficient matrix, [X]nx1 is the solution vector, and [C]nx1 is the right hand side array. It is the application of Gaussian elimination to solve systems of linear equations with the assumption that pivot values will never be zero. Naive Gauss consists of two steps:
1) Forward Elimination: In this step, the unknown is eliminated in equation starting with the first equation. This way, the equations are ‘reduced’ to one equation and one unknown in each equation.
2) Back Substitution: In this step, starting from the last equation, each of the unknowns is found.
Gaussian elimination attempts to convert a system of linear equations from a form like:
into a form like:
A critical step in this process is the ability to divide row values by the value of a ‘pivot entry’ (the value of an entry along the top-left to bottom-right of (a possibly modified) coefficient matrix.
Naive Gaussian Elimination assumes that this division will always be possible i.e. that the pivot value will never be zero. (Note, by the way, a pivot value close to but not necessarily equal to zero, can make the results unreliable when working with calculators or computers with limited accuracy).