How to compute $\sin(At)$ if $A$ is a $3\times 3$ matrix? MATLAB code would also help me.
 A: Suppose the $n \times n$ matrix $A$ has $n$ distinct eigenvalues $\lambda_j$.  Then
for any analytic function $f$, $$f(A) = f(\lambda_1) P_1(A) + f(\lambda_2) P_2(A) + f(\lambda_3) P_3(A)$$
where
$$ P_j(z) = \prod_{i \in \{1,\ldots,n\} \backslash \{j\}} \frac{z-\lambda_i}{\lambda_j - \lambda_i}$$
In the case $n=3$, that is
$$ \eqalign{P_1(z) &= \dfrac{(z-\lambda_2)(z-\lambda_3)}{(\lambda_1-\lambda_2)(\lambda_1-\lambda_3)}\cr
P_2(z) &= \dfrac{(z-\lambda_1)(z-\lambda_3)}{(\lambda_2-\lambda_1)(\lambda_2-\lambda_3)}\cr
P_3(z) &= \dfrac{(z-\lambda_1)(z-\lambda_2)}{(\lambda_3-\lambda_1)(\lambda_3-\lambda_2)}\cr}$$
If the eigenvalues are not distinct, you need to modify this.  In general what you want is: $f(A) = g(A)$ where $g(z)$ is a polynomial of degree $n$ such that for each eigenvalue $\lambda$ of algebraic multiplicity $m$, 
$g(\lambda) = f(\lambda)$ and $g^{(k)}(\lambda) = f^{(k)}(\lambda)$ for 
$1 \le k \le m-1$.
A: $$\sin(At)=\frac{\exp(iAt)-\exp(-iAt)}{2i}$$
We can compute exponential of a matrix in Matlab.
A: Put the matrix into Jordan canonical form. Jordan form is perfect for this because, for example,
$$
       A=\left[\begin{array}{ccc}\lambda & 1 & 0 \\ 0 & \lambda & 1 \\ 0 & 0 &\lambda\end{array}\right] = \lambda I + N
$$
where $N^3=0$. Then because $\lambda I$ and $N$ commute,
\begin{align}
    \sin(\lambda I+N)& =\sin(\lambda I)\cos(N)+\cos(\lambda I)\sin(N) \\
      & = \sin(\lambda)(I-\frac{1}{2!}N^2)+\cos(\lambda)N \\
      & = \left[\begin{array}{ccc} \sin(\lambda) & \cos(\lambda) & -\frac{\sin(\lambda)}{2!} \\
   0 & \sin(\lambda) & \cos(\lambda) \\ 0 & 0 & \sin(\lambda)
              \end{array}\right]
\end{align}
This may be applied to each Jordan block individually.
Finally, to look at $\sin(tA)$,
\begin{align}
     \sin(tA) & = \sin(\lambda t I + t N) \\
     & =\sin(\lambda tI)\cos(tN)+\cos(\lambda tI)\sin(tN) \\
     & =\sin(\lambda t)(I-\frac{t^2}{2!}N^2)+\cos(\lambda t)tN \\
     & =\left[\begin{array}{ccc}
              \sin(\lambda t) & t\cos(\lambda t) & -\frac{t^2\sin(\lambda t)}{2!} \\
                  0 & \sin(\lambda t) &  t\cos(\lambda t)\\
                  0 & 0 & \sin(\lambda t)
               \end{array}\right]
\end{align}
A: If $A$ is Hermitian or anti-hermitian, then you can perform an eigen-decomposition of the matrix, $A$. That will give you a matrix of eigenvalues on the diagonal, called $\Lambda$, and a matrix of orthonormal eigenvectors, $V$. We have: $$A = V^T \Lambda V.$$ With that decomposition it is possible to evaluate any function that can be expressed as a power series, $P(x)$, using:
$$P(A) = V^T P(\Lambda) V,$$ as long as the series is convergent for all of $A$'s eigenvalues, because of the identity $\left( V^T \Lambda V \right)^n = V^T \Lambda^n V$. In short: $$\sin\left(At\right) = V^T \sin\left(\Lambda t\right) V,$$ and $\sin\left(\Lambda t\right)$ can be evaluated element-wise because it is diagonal.
