The Cosine of a Matrix

To find the cosine of a square matrix  
\[A\]
  (we can only find the cosine, or indeed any function of a matrix if it is square), first write down the Mclaurin series for  
\[cos \: A\]
:
\[cos \: A = I- \frac{A^2}{2!}+\frac{A^4}{4!} +...+ (-1)^{n} \frac{A^{2n}}{(2n)!}+...\]
.
It might be hard to find and add all these powers of  
\[A\]
. We can simplify by diagonalising  
\[A\]
.
Example: Let  
\[A= \left( \begin{array}{cc} 2 & 1 \\ 1 & 2 \end{array} \right) \]
.
To diagonalize  
\[A\]
  first find the eigenvalues, the solution to  
\[det(A- \lambda I)=0\]
.
\[\begin{equation} \begin{aligned} det(A- \lambda I) &= \left| \begin{array}{cc} 2- \lambda & 1 \\ 1 & 2- \lambda \end{array} \right| \\ &= (2- \lambda)^2-1^2 \\ &= \lambda^2 - 4 \lambda +3 \\ &=(\lambda -3)(\lambda -1) \end{aligned} \end{equation}\]
.
Hence  
\[\lambda =3, \: \lambda=1 \]
.
Now find the eigenvectors. These are the solutions to  
\[(A- \lambda I) \mathbf{v}= \mathbf{0}\]

If  
\[\lambda =3 \]
.
\[(A- \lambda I) \mathbf{v} = \left( \begin{array}{cc} -1 & 1 \\ 1 & -1 \end{array} \right) \begin{pmatrix}v_1\\v_2\end{pmatrix}= \begin{pmatrix}-v_1+v_2\\v_1-v_2\end{pmatrix}= \begin{pmatrix}0\\0\end{pmatrix}\]
.
Hence we can take  
\[v_1=v_2=1\]
. The first eigenvector is  
\[\begin{pmatrix}1\\1\end{pmatrix} \]
.
If  
\[\lambda =1 \]
.
\[(A- \lambda I) \mathbf{v} = \left( \begin{array}{cc} 1 & 1 \\ 1 & 1 \end{array} \right) \begin{pmatrix}v_1\\v_2\end{pmatrix}= \begin{pmatrix}v_1+v_2\\v_1+v_2\end{pmatrix}= \begin{pmatrix}0\\0\end{pmatrix}\]
.
Hence we can take  
\[v_1=1, \: v_2=-1\]
. The second eigenvector is  
\[\begin{pmatrix}1\\-1\end{pmatrix} \]
.
Now form the matrix  
\[P= \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right)\]
  of eigenvectors and the corresponding diagonal matrix  
\[D=\left( \begin{array}{cc} 3 & 0 \\ 0 & 1 \end{array} \right)\]
  containing the eigenvalues. The relationship between  
\[A, \: P, \: D\]
  is  
\[D=P^{-1}AP\]
.
To find powers of  
\[A\]
  we can use  
\[PDP^{-1}=A \rightarrow A^n =\underbrace{(PDP^{-1})...(PDP^{-1})}_{n \: times}=PD^nP^{-1}\]
.
\[\begin{equation} \begin{aligned} cos \: A &=I- \frac{(PDP^{-1})^2}{2!}+\frac{(PDP^{-1})^4}{4!} +...+ (-1)^n\frac{(PDP^{-1})^{2n}}{(2n)!}+... \\ &= P(I-\frac{D^2}{2!}+\frac{D^4}{4!} +...+ (-1)^n \frac{D^{2n}}{(2n)!}+...)P^{-1} \\ &= P cos \: D P^{-1} \\ &= \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right) \left( \begin{array}{cc} cos \: 3 & 0 \\ 0 & cos \: 1 \end{array} \right) \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right)^{-1} \\ &= \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right) \left( \begin{array}{cc} cos \: 3 & 0 \\ 0 & cos \: 1 \end{array} \right) \frac{-1}{2} \left( \begin{array}{cc} -1 & -1 \\ -1 & 1 \end{array} \right) \\ &= \frac{1}{2} \left( \begin{array}{cc} cos \: 3+cos \: 1 & cos \: -cos \: 1 \\ cos \: 3-cos \: 1 & cos \: 3+ cos \: 1 \end{array} \right) \end{aligned} \end{equation}\]
.