Activity5.1.4
Sage will create \(LU\) factorizations; once we have a matrix A, we write P, L, U = A.LU() to obtain the matrices \(P\text{,}\) \(L\text{,}\) and \(U\) such that \(PA = LU\text{.}\)

In the previous activity, we found the \(LU\) factorization
\begin{equation*} A = \left[\begin{array}{rrr} 1 \amp 2 \amp 1 \\ 2 \amp 3 \amp 2 \\ 3 \amp 7 \amp 4 \\ \end{array}\right] = LU = \left[\begin{array}{rrr} 1 \amp 0 \amp 0 \\ 2 \amp 1 \amp 0 \\ 3 \amp 1 \amp 1 \end{array}\right] \left[\begin{array}{rrr} 1 \amp 2 \amp 1 \\ 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp 1 \\ \end{array}\right]\text{.} \end{equation*}Using Sage, define the matrix \(A\) and then ask Sage for the \(LU\) factorization. What are the matrices \(P\text{,}\) \(L\text{,}\) and \(U\text{?}\)
Notice that Sage finds a different \(LU\) factorization than we found in the previous activity. This is because Sage uses partial pivoting, as described in the previous section, when it performs Gaussian elimination. This is reflected by the fact that the permutation \(P\) is not the identity.
Define the vector \(\bvec = \threevec{3}{5}{8}\) in Sage and compute \(P\bvec\text{.}\)
Use the matrices L and U to solve \(L\cvec = P\bvec\) and \(U\xvec = \cvec\text{.}\) You should find the same solution \(\xvec\) that you found in the previous activity.
Use the factorization to solve the equation \(A\xvec = \threevec{11}{17}{35}\text{.}\)
How does the factorization show us that \(A\) is invertible and that, therefore, every equation \(A\xvec=\bvec\) has a unique solution?

Suppose that we have the matrix
\begin{equation*} A = \left[\begin{array}{rrr} 3 \amp 1 \amp 2 \\ 2 \amp 1 \amp 1 \\ 2 \amp 1 \amp 3 \\ \end{array}\right] \text{.} \end{equation*}Use Sage to find the \(LU\) factorization. Explain how the factorization shows that \(A\) is not invertible.

Consider the matrix
\begin{equation*} A = \left[\begin{array}{rrrr} 2 \amp 1 \amp 2 \amp 3 \\ 1 \amp 1 \amp 0 \amp 2 \\ 3 \amp 2 \amp 1 \amp 2 \\ \end{array}\right] \end{equation*}and find its \(LU\) factorization. Explain why \(A\) and \(U\) have the same null space and use this observation to find a basis for \(\nul(A)\text{.}\)