TITLE: Pivoting in LU decomposition
QUESTION [6 upvotes]: I tried to find some reference on the net but couldn't find a good one. What is the advantage of pivoting in LU decomposition over regular LU decomposition? Is it something to do with matrix singular or not?

REPLY [6 votes]: To further generalize Rahul's answer, any matrix that has a singular leading block cannot have an LU decomposition. By allowing pivoting (or in matrix factorization terms, allowing the multiplication of your original matrix by an appropriate permutation matrix), all matrices admit an LU decomposition. This is the explanation for pivoting in exact arithmetic.
In inexact arithmetic, the condition "singular" in the explanation above is replaced by the term "ill-conditioned". Every matrix has an associated condition number, which is defined as the product of the norm of the matrix and the norm of its inverse. In attempting to proceed with the LU decomposition of a matrix with an ill-conditioned leading block, you will hit a point where you have to divide by a small number (resulting in a number that may be much larger in magnitude than the matrix's original entries), which causes all sorts of trouble in the succeeding additions/subtractions that have to be done to finish the LU decomposition.
By pivoting, we avoid (or at the very least delay) the onset of encountering numbers much larger than the entries of the original matrix, which is one way precision is lost in the operations.
Of course, one could make the objection that the coefficients are badly scaled: for instance, if you have two equations in two unknowns, and you multiply both sides of any of the two equations by a number much smaller or much larger than the original coefficients, the solution to the system is still the same, but attempting to perform LU decomposition on the transformed system can be disastrous. This is where concepts like "scaled pivoting" comes in, where relative instead of absolute magnitudes are taken into account in the selection of pivots.
Then there are applications where "partial pivoting" (swapping of rows) is not enough; rank determination of a matrix, for instance, requires "complete pivoting" (swapping of both rows and columns).
In short, LU decomposition behaves much better with pivoting.
(I have been intentionally vague in some parts; you would do well to read Golub and Van Loan, as already recommended by jmoy, or the books "Matrix Decompositions" by Stewart or "Applied Numerical Linear Algebra" by Demmel for more rigorous versions of my explanation.)