If $A=\left(\begin{array}{cc} 2 & 1\\ 1 & 3 \end{array}\right)$, find $\cos\left(\frac{A\pi}{6}\right)$ find $\cos\left(\frac{A\pi}{6}\right)$ with  $$A=\left(\begin{array}{cc} 2 & 1\\ 1 & 3 \end{array}\right)$$, 

I don't know to calculate cosine of the matrix. I know $\cos(A)=I−A^2/2!+A^4/4!−A^6/6!+⋯$ . How to find it? $\cos(A)$ is infinite series, what to do

 A: Hint: Find the matrix P such that 
$$A=\left(\begin{array}{cc} 2 & 1\\ 1 & 3 \end{array}\right) =P\left(\begin{array}{cc} x_1 & 0\\ 0 & x_2 \end{array}\right)P^{-1}$$
Where 
$$x_1=\frac{5+\sqrt5}{2} \, \text{ and }\, x_2=\frac{5-\sqrt5}{2}$$ and the eigenvalue of A.
Then from the fact that 
$$\cos(tA)=\sum_{n=0}^{\infty}(-1)^n\frac{(tA)^{2n}}{(2n)!} $$
you easily get: $$\cos (tA)=P\left(\begin{array}{cc} \cos (tx_1) & 0\\ 0 & \cos(t x_2) \end{array}\right)P^{-1}$$
A: It is easy to calculate the quantities
$$\eqalign{
 T = {\rm tr}(A) \cr
 D = \det(A) \cr
}$$
for a $2\times 2$ matrix.
In terms of these, the eigenvalues are
$$\eqalign{
 \lambda = \frac{T\pm\sqrt{T^2-4D}}{2} \cr
}$$
Any holomorphic function of  $A\in{\mathbb C}^{n\times n}$ can be written as a $(n\!-\!1)^{th}$ order polynomial. 
In this case $n=2$, so the polynomial is linear 
$$f(A) = c_1A + c_0I$$
This linear equation also applies to the eigenvalues 
$$\eqalign{
 c_1\lambda_1 + c_0 &= f(\lambda_1) = f_1 \cr
 c_1\lambda_2 + c_0 &= f(\lambda_2) = f_2 \cr
}$$
allowing the coefficients to be solved in closed-form
$$\eqalign{
 c_1 &= \frac{f_2-f_1}{\lambda_2-\lambda_1} \cr
 c_0 &= f_1 - c_1\lambda_1 = \frac{\lambda_2f_1-\lambda_1f_2}{\lambda_2-\lambda_1} \cr
}$$
In the case of a repeated eigenvalue $(\lambda_1=\lambda_2=\lambda)$, l'Hospital's rule yields
$$c_1 = f^\prime(\lambda),\,\,\,\,\,\,c_0=f(\lambda)-\lambda f^\prime(\lambda)$$
You now have a formula to calculate nearly any function of any $2\times 2$ matrix. 
In the present problem, 
$$\eqalign{
 T &= D = 5 \cr
 \lambda_k &\in \bigg\{ \frac{5-\sqrt{5}}{2},\,\,\,\frac{5+\sqrt{5}}{2} \bigg\} 
 &= \big\{1.38196601,\, 3.61803399\big\} \cr
 f_k &= f(\lambda_k) = \cos\bigg(\frac{\pi\lambda_k}{6}\bigg)
 &= \big\{0.74942992,\,-0.31798351\big\} \cr
 f(A) &= \bigg(\frac{f_2-f_1}{\lambda_2-\lambda_1}\bigg)A + \bigg(\frac{\lambda_2f_1-\lambda_1f_2}{\lambda_2-\lambda_1}\bigg)I \cr
\cr
 &= -0.477361795\,A + 1.40912769\,I \cr
\cr
 &= \begin{bmatrix}0.454404 & -0.477362 \\
 -0.477362 & -0.0229577\end{bmatrix}  \cr\cr
}$$
