How to LU facctorisation of a 4 by 4 matrice using gaussian eilimination! I have a 4 by 4 matrice,
A = [2 -2 0 0]
    [2 -4 2 0]
    [0 -2 4 -2]
    [0 0 2 -4]
How would I use Gaussian Elimination to find the LU factorisation of the matrix
Please could someone explain how to do this!? I have an exam where a similar question will come up so i really want to be able to fully understand this. I can do and completely understand Gaussian elimination of a 3 by 3 matrix but not when it is not a system on equations! I havnt seen anything like this before!
Many thanks
 A: Here's your matrix $A$, and you multiply it on the left with a 4 by 4 Identity matrix (it's always going to be the same dimensions as your $A$ matrix). So it'll look like $[I]*[A]$, and then you do Gaussian Elimination (GE) to your $A$ matrix, and make sure you keep track of your row operations that you do. Ex that's not important to your question: 
$$\
r_{2} = r_{2} - 2r_{1}$$
When you apply it to your Identity matrix, make sure you change it to:
$$\
c_{1} = c_{1} + 2c_{2}$$
Where you then apply it as a column operation to the identity matrix. You keep doing those same steps until you end with your lower triangular matrix ($L$) on the left, and an upper triangular matrix on the right ($U$). Then $A = LU$. I will post an actual example soon.
Note: If you have to switch rows, then you have to multiply by a Permutation matrix, P. The steps you would do it would be PAx = Pb. I will write out an example, and somehow figure out how to post it here.
A: Hint: In general, we premultiply matrix $A$ to get upper traiangular matrix $U$,i.e $$ (HGFE)A = U $$
then $$A=(HGFE)^{-1}U$$
$$A = E^{-1}F^{-1}G^{-1}H^{-1}U$$
$$A=LU$$ where $L = E^{-1}F^{-1}G^{-1}H^{-1}$
A: Disclaimer I will use MATLAB notation for indexing the matrix. i.e. $A(i,j)=A_{ij}$.
Firstly, the standard Gaussian elimination without pivotting is:
Given an $n\times n$ matrix $A$,

for i = 1:n-1
    for j = i+1:n
        m =A (j,i)/A(i,i);
        A(j,i) = 0;
        for k = i+1:n
            A(j,k) = A(j,k) - m*A(i,k);
        end
    end
end

By simply changing the third line to
        A(j,i) = m;

at the completion of this section of code, the matrix $A$ will be of the form $L+U-I$, where $L$ and $U$ are the factors of the LU factorisation and $I$ is an appropriately sized identity matrix.
In other words, (in MATLAB notation) you can get the LU factorisation after this algorithm by
L = tril(A,-1)+eye(n);
U = triu(A,0;

The MATLAB functions tril and triu return the upper and lower portions of the input matrix and eye(n) returns an $n\times n$ identity matrix.
Using your matrix, you would have
$$A=\begin{bmatrix}2&-2&0&0\\2&-4&2&0\\0&-2&4&-2\\0&0&2&-4\end{bmatrix}$$ before you run this algorithm. After you run the algorithm it would be
$$A=\begin{bmatrix}2&-2&0&0\\1&-2&2&0\\0&1&2&-2\\0&0&1&-2\end{bmatrix}$$ from which you can read off the LU factorisation:
$$L=\begin{bmatrix}1&0&0&0\\1&1&0&0\\0&1&1&0\\0&0&1&1\end{bmatrix} \text{ and }
U=\begin{bmatrix}2&-2&0&0\\0&-2&2&0\\0&0&2&-2\\0&0&0&-2\end{bmatrix}.$$ Rhe ones on the diagonal of $L$ come from adding the identity matrix.
