Gaussian elimination: Difference between revisions
m and rm reduntant link |
m see:Talk:Gaussian_elimination#As_of_2007-05-17 |
||
Line 1: | Line 1: | ||
{{Citecheck|date=February 2007}} <!-- Mathworld says Gaussian takes only to ref, not rref! --> |
{{Citecheck|date=February 2007}} <!-- Mathworld says Gaussian takes only to ref, not rref! --> |
||
{{contradict|about=reduced row echelon form}} |
|||
{{contradict-other|Gauss–Jordan elimination}} |
|||
In [[linear algebra]], '''Gaussian elimination''' is an [[algorithm]] which can be used to determine the solutions of a [[system of linear equations]], to find the [[Rank (linear algebra)|rank]] of a [[matrix (mathematics)|matrix]], and to calculate the inverse of an [[invertible matrix|invertible square matrix]]. Formally, the Gaussian elimination algorithm takes an arbitrary [[system of linear equations]] as input and returns its solution vector, if it exists and is unique. Equivalently, the algorithm takes an arbitrary matrix and reduces it to [[row echelon form]]. [[Elementary operations]] are used throughout the algorithm. Gaussian elimination is named after German mathematician and scientist [[Carl Friedrich Gauss]]. |
In [[linear algebra]], '''Gaussian elimination''' is an [[algorithm]] which can be used to determine the solutions of a [[system of linear equations]], to find the [[Rank (linear algebra)|rank]] of a [[matrix (mathematics)|matrix]], and to calculate the inverse of an [[invertible matrix|invertible square matrix]]. Formally, the Gaussian elimination algorithm takes an arbitrary [[system of linear equations]] as input and returns its solution vector, if it exists and is unique. Equivalently, the algorithm takes an arbitrary matrix and reduces it to [[row echelon form]]. [[Elementary operations]] are used throughout the algorithm. Gaussian elimination is named after German mathematician and scientist [[Carl Friedrich Gauss]]. |
||
Revision as of 02:12, 18 May 2007
![]() |
![]() | This article or section appears to contradict itself on reduced row echelon form. |
![]() | This article appears to contradict the article Gauss–Jordan elimination. |
In linear algebra, Gaussian elimination is an algorithm which can be used to determine the solutions of a system of linear equations, to find the rank of a matrix, and to calculate the inverse of an invertible square matrix. Formally, the Gaussian elimination algorithm takes an arbitrary system of linear equations as input and returns its solution vector, if it exists and is unique. Equivalently, the algorithm takes an arbitrary matrix and reduces it to row echelon form. Elementary operations are used throughout the algorithm. Gaussian elimination is named after German mathematician and scientist Carl Friedrich Gauss.
A related but less-efficient algorithm, Gauss–Jordan elimination, brings a matrix to reduced row echelon form, whereas Gaussian elimination takes it only as far as row echelon form.
History
Although the method is named after mathematician Carl Friedrich Gauss, the earliest presentation of it can be found in the important Chinese mathematical text Jiuzhang suanshu or The Nine Chapters on the Mathematical Art, dated approximately 150 B.C.E, and commented on by Liu Hui in the 3rd century.
Algorithm overview
The process of Gaussian elimination has two parts. The first part (Forward Elimination) reduces a given system to either triangular or echelon form, or results in a degenerate equation with no solution, indicating the system has no solution. This is accomplished through the use of elementary operations. The second step (Backward Elimination) uses back-substitution to find the solution of the system above.
Stated equivalently for matrices, the first part reduces a matrix to row echelon form using elementary operations while the second reduces it to reduced row echelon form, or row canonical form.
Another point of view, which turns out to be very useful to analyze the algorithm, is that Gaussian elimination computes a matrix decomposition. The three elementary operations used in the Gaussian elimination (multiplying rows, switching rows, and adding multiples of rows to other rows) amount to multiplying the original matrix with invertible matrices from the left. The first part of the algorithm computes an LU decomposition, while the second part writes the original matrix as the product of a uniquely determined invertible matrix and a uniquely determined reduced row-echelon matrix.
Example
Suppose the goal is to find and describe the solution(s), if any, of the following system of linear equations:
The algorithm is as follows: eliminate from all equations below , and then eliminate from all equations below . This will put the system into triangular form. Then, using back-substitution, each unknown can be solved for.
In our example, we eliminate from by adding to , and then we eliminate from by adding to . Formally:
The result is:
Now we eliminate from by adding to :
The result is:
This result is a system of linear equations in triangular form, and so the first part of the algorithm is complete.
The second part, back-substitution, consists of solving for the unknowns in reverse order. Thus, we can easily see that
Then, can be substituted into , which can then be solved easily to obtain
Next, and can be substituted into , which can be solved to obtain
Thus, the system is solved.
This algorithm works for any system of linear equations. It is possible that the system cannot be reduced to triangular form, yet still have at least one valid solution: for example, if had not occurred in and after our first step above, the algorithm would have been unable to reduce the system to triangular form. However, it would still have reduced the system to echelon form. In this case, the system does not have a unique solution, as it contains at least one free variable. The solution set can then be expressed parametrically (that is, in terms of the free variables, so that if values for the free variables are chosen, a solution will be generated).
In practice, one does not usually deal with the actual systems in terms of equations but instead makes use of the augmented matrix (which is also suitable for computer manipulations). This, then, is the Gaussian Elimination algorithm applied to the augmented matrix of the system above, beginning with:
which, at the end of the first part of the algorithm looks like this:
That is, it is in row echelon form.
At the end of the algorithm, we are left with
That is, it is in reduced row echelon form, or row canonical form.
Other applications
Finding the inverse of a matrix
Suppose is a matrix and you need to calculate its inverse. The identity matrix is augmented to the right of , forming a matrix (the block matrix ). Through application of elementary row operations and the Gaussian elimination algorithm, the left block of can be reduced to the identity matrix , which leaves in the right block of .
If the algorithm is unable to reduce to triangular form, then is not invertible.
In practice, inverting a matrix is rarely required. Most of the time, one is really after the solution of a particular system of linear equations.[1]
The general algorithm to compute ranks and bases
The Gaussian elimination algorithm can be applied to any matrix . If we get "stuck" in a given column, we move to the next column. In this way, for example, any matrix can be transformed to a matrix that has a reduced row echelon form like
(the *'s are arbitrary entries). This echelon matrix contains a wealth of information about : the rank of is 5 since there are 5 non-zero rows in ; the vector space spanned by the columns of has as basis the first, third, fourth, seventh and ninth column of (the columns of the ones in ), and the *'s tell you how the other columns of can be written as linear combinations of the basis columns.
Analysis
Gaussian elimination on an n × n matrix requires approximately 2n3 / 3 operations.
This algorithm can be used on a computer for systems with thousands of equations and unknowns. However, the cost becomes prohibitive for systems with millions of equations. These large systems are generally solved using iterative methods. Specific methods exist for systems whose coefficients follow a regular pattern (see system of linear equations).
The Gaussian elimination can be performed over any field.
Gaussian elimination is numerically stable for diagonally dominant or positive-definite matrices. For general matrices, Gaussian elimination is usually considered to be stable in practice if you use partial pivoting as described below, even though there are examples for which it is unstable.[2]
Pseudocode
As explained above, Gaussian elimination writes a given m × n matrix A uniquely as a product of an invertible m × m matrix S and a row-echelon matrix T. Here, S is the product of the matrices corresponding to the row operations performed.
The formal algorithm to compute from follows. We write for the entry in row , column in matrix . The transformation is performed "in place", meaning that the original matrix is lost and successively replaced by .
i := 1
j := 1
while (i ≤ m and j ≤ n) do
Find pivot in column j, starting in row i:
maxi := i
for k := i+1 to m do
if abs(A[k,j]) > abs(A[maxi,j]) then
maxi := k
end if
end for
if A[maxi,j] ≠ 0 then
swap rows i and maxi, but do not change the value of i
Now A[i,j] will contain the old value of A[maxi,j].
divide each entry in row i by A[i,j]
Now A[i,j] will have the value 1.
for u := i+1 to m do
subtract A[u,j] * row i from row u
Now A[u,j] will be 0, since A[u,j] - A[i,j] * A[u,j] = A[u,j] - 1 * A[u,j] = 0.
end for
i := i + 1
end if
j := j + 1
end while
This algorithm differs slightly from the one discussed earlier, because before eliminating a variable, it first exchanges rows to move the entry with the largest absolute value to the "pivot position". Such a pivoting procedure improves the numerical stability of the algorithm; some variants are also in use.
The column currently being transformed is called the pivot column. Proceed from left to right, letting the pivot column be the first column, then the second column, etc. and finally the last column before the vertical line. For each pivot column, do the following two steps before moving on to the next pivot column:
- Locate the diagonal element in the pivot column. This element is called the pivot. The row containing the pivot is called the pivot row. Divide every element in the pivot row by the pivot to get a new pivot row with a 1 in the pivot position.
- Get a 0 in each position below the pivot position by subtracting a suitable multiple of the pivot row from each of the rows below it.
Upon completion of this procedure the augmented matrix will be in row-echelon form and may be solved by back-substitution.
See also
Notes
References
- Atkinson, Kendall A. An Introduction to Numerical Analysis, 2nd edition, John Wiley & Sons, New York, 1989. ISBN 0-471-50023-2.
- Golub, Gene H., and Van Loan, Charles F. Matrix computations, 3rd edition, Johns Hopkins, Baltimore, 1996. ISBN 0-8018-5414-8.
- Lipschutz, Seymour, and Lipson, Mark. Schaum's Outlines: Linear Algebra. Tata McGraw-hill edition.Delhi 2001. pp. 69-80.
External links
- Gaussian elimination www.math-linux.com.
- Gaussian elimination as java applet at some local site. Only takes natural coefficients.
- Gaussian elimination at Holistic Numerical Methods Institute
- LinearEquations.c Gaussian elimination implemented using C language