TITLE: Getting the inverse of a lower/upper triangular matrix
QUESTION [45 upvotes]: For a lower triangular matrix, the inverse of itself should be easy to find because that's the idea of the LU decomposition, am I right? For many of the lower or upper triangular matrices, often I could just flip the signs to get its inverse. For eg: $$\begin{bmatrix}
1 & 0 & 0\\ 
0 & 1 & 0\\ 
-1.5 & 0 & 1
\end{bmatrix}^{-1}=
\begin{bmatrix}
1 & 0 & 0\\ 
0 & 1 & 0\\ 
1.5 & 0 & 1
\end{bmatrix}$$
I just flipped from -1.5 to 1.5 and I got the inverse.
But this apparently doesn't work all the time. Say in this matrix: 
$$\begin{bmatrix}
1 & 0 & 0\\ 
-2 & 1 & 0\\ 
3.5 & -2.5 & 1
\end{bmatrix}^{-1}\neq 
\begin{bmatrix}
1 & 0 & 0\\ 
2 & 1 & 0\\ 
-3.5 & 2.5 & 1
\end{bmatrix}$$
By flipping the signs, the inverse is wrong.
But if I go through the whole tedious step of gauss-jordan elimination, I would get its correct inverse like this: $\begin{bmatrix}
1 & 0 & 0\\ 
-2 & 1 & 0\\ 
3.5 & -2.5 & 1
\end{bmatrix}^{-1}=
\begin{bmatrix}
1 & 0 & 0\\ 
2 & 1 & 0\\ 
1.5 & 2.5 & 1
\end{bmatrix}$
And it looks like some entries could just flip its signs but not for others.
Then this is kind of weird because I thought the whole idea of getting the lower and upper triangular matrices is to avoid the need to go through the tedious process of gauss-jordan elimination and can get the inverse quickly by flipping signs? Maybe I have missed something out here. How should I get an inverse of a lower or an upper matrix quickly?

REPLY [2 votes]: Given that the diagonal elements of a triangular matrix $A$ are all $1$. It is immediate to see that the characteristic polynomial of $A$ is
\begin{align*}
f(\lambda) = \det(\lambda I_{(n)} - A) = (\lambda - 1)^n = 
\lambda^n - \binom{n}{1}\lambda^{n - 1} + \binom{n}{2}\lambda^{n - 2} + \cdots + (-1)^n.
\end{align*}
By Cayley-Hamilton theorem, this ensues
\begin{align*}
0 = A^n - \binom{n}{1}A^{n - 1} + \binom{n}{2}A^{n - 2} + \cdots + (-1)^nI_{(n)}.
\end{align*}
Rearranging terms yields
\begin{align*}
A \left((-1)^nA^{n - 1} + (-1)^{n + 1}\binom{n}{1}A^{n - 2} + (-1)^{n + 2}\binom{n}{2}A^{n - 3} + \cdots + (-1)^{2n - 1}\binom{n}{n - 1}I_{(n)}\right) = I_{(n)}.
\end{align*}
By definition, this shows
\begin{align*}
A^{-1} = (-1)^nA^{n - 1} + (-1)^{n + 1}\binom{n}{1}A^{n - 2} + (-1)^{n + 2}\binom{n}{2}A^{n - 3} + \cdots + (-1)^{2n - 1}\binom{n}{n - 1}I_{(n)}.
\end{align*}
When $n$ is small, this formula should be easy to apply.