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

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.
