TITLE: Writing an invertible $2\times2$ matrix as a conjugate of an upper triangular matrix
QUESTION [5 upvotes]: It's been a while since I've studied linear algebra, and I wanted to follow up on something I read on MathOverflow. 
In this answer, KConrad mentions you can write any invertible $2\times2$ matrix as a conjugate of an upper triangular matrix. How does this work again?
If I wanted to more formally pose my question:
Suppose $A=\begin{bmatrix} a & b \\ c & d\end{bmatrix}\in GL_2(\mathbb{C})$. How could I determine matrices $B$ and $C$ such that $A=CBC^{-1}$ with $B$ upper triangular?

REPLY [2 votes]: First calculate the characteristic polynomial, i.e. $\det(A-xI)$, where $x$ is an indeterminate. Then get the roots, if they are different your matrix $B$ is $$\begin{bmatrix}\lambda_1 &0\\0 &\lambda_2\end{bmatrix}.$$
Otherwise your matrix $B$ is either
$$\begin{bmatrix}\lambda_1 & 0\\\ 0&\lambda_1\end{bmatrix} \, \text{or}\, \begin{bmatrix}\lambda_1 & 1\\0&\lambda_1\end{bmatrix}.$$
For computing the matrix $C$ (and $B$) you have to compute the spaces $\ker(A-\lambda_1 I)$ and $\ker(A-\lambda_2 I)$ and $\ker (A-\lambda_1 I)^2$. Then take a basis of $\ker(A-\lambda_1 I)$ and complement it to a basis of $\ker(A-\lambda_1I)^2$. After rescaling your matrix $A$ will look like one in the second line with respect to this basis. The matrix $C$ is the base change matrix.
EDIT: Of course this is just the normal form explained in this concrete example as it was said in the comment.

REPLY [2 votes]: Actually any complex square matrix (invertible or not and regardless of size) can be unitarily triangularized. The theoretical way to illustrate this fact is quite standand. For a $2\times 2$ matrix $A$, let $u=(x,y)^T$ be an eigenvector of $A$ corresponding to some eigenvalue $\lambda$. Normalize $u$ (i.e. $u\leftarrow u/(u^\ast u)$) to make it a unit vector. Let $U=\begin{pmatrix} x & -\bar{y} \\ y & \bar{x}\end{pmatrix}$. Then $U$ is a unitary matrix with $U^{-1}=U^\ast$ (the asterisk means conjugate transpose, i.e. $X^\ast=\bar{X}^T$) and hence the  $(2,1)$-th entry of $U^{-1}AU$ is given by
$$
\begin{eqnarray}
&&(\textrm{2nd row of } U^{-1}) (A)(\textrm{1st col. of } U)\\
&=&(\textrm{2nd row of } U^\ast)\ (A)\ (\textrm{1st col. of } U)\\
&=&\begin{pmatrix} -y & x\end{pmatrix}
A
\begin{pmatrix} x\\y\end{pmatrix}
=
\begin{pmatrix} -y & x\end{pmatrix}
\lambda
\begin{pmatrix} x\\y\end{pmatrix}
=0.
\end{eqnarray}
$$
Since the $(2,1)$-th entry is zero, $B=U^{-1}AU$ is upper triangular.

REPLY [2 votes]: You have two options, depending on whether you are working in exact or inexact arithmetic.
For exact arithmetic, Billy has mentioned the Jordan decomposition: in the decomposition $\mathbf A=\mathbf C\mathbf B\mathbf C^{-1}$, $\mathbf B$ can be diagonal if $\mathbf A$ is not defective; i.e. $\mathbf A$ has a complete eigenvector set (and thus the Jordan decomposition and eigendecomposition are equivalent in this case). If $\mathbf A$ is defective, $\mathbf B$ will have the form of a Jordan block:
$$\mathbf B=\begin{pmatrix}\lambda&1\\0&\lambda\end{pmatrix}$$
where $\lambda$ is the sole eigenvalue of $\mathbf A$.
In inexact arithmetic, the computation of the Jordan decomposition can be unstable. (See this article for a discussion of the difficulties.) The appropriate decomposition here is the Schur decomposition: here, in the decomposition $\mathbf A=\mathbf C\mathbf B\mathbf C^{-1}$, $\mathbf C$ is chosen to be unitary, $\mathbf C^{-1}=\mathbf C^{\ast}$. $\mathbf B$ becomes triangular.
If $\mathbf A$ is real and the eigenvalues of $\mathbf A$ are all real, then this decomposition can be done with an orthogonal matrix $\mathbf C$ for real $\mathbf A$. But if the two eigenvalues are complex conjugates, one must necessarily use a unitary $\mathbf C$ for decomposing $\mathbf A$. The best one can do with an orthogonal $\mathbf C$ in this case is to have $\mathbf B$ in the form
$$\mathbf B=\begin{pmatrix}\lambda&u\\v&\lambda\end{pmatrix}$$
where $\lambda\pm i\mu$ are the eigenvalues of $\mathbf A$, and $uv=-\mu$.