# Matrix exponentiation – what’s that?

Most people have heard of the exponential function that maps an arbitrary real (or even complex) number x to $e^x$ but what happens if x is not a number but a matrix? Does the expression $e^A$ with a square matrix $A$ even make sense?

The answer is: Yes, it does!

In order to understand what the expression $e^A$ means, we take a step back to the exponential function for scalars. When we have a look at the power series of the exponential function,

$\exp(x) = \sum_{n=0}^{\infty} \frac{x^n}{n!}$ with $x \in \mathbb{C}$,

we can see that there are only multiplications, additions and divisions by a scalar involved. These operations can be generalized to matrices easily. Hence, we can define the exponential of a matrix $A$ as

$\exp(A) = \sum_{n=0}^{\infty} \frac{A^n}{n!}$.

The next question is: How can we compute the matrix exponential for a general complex matrix?

There exist several different algorithms, our project focuses on two of them: Taylor series and diagonalization.

The most intuitive one is using the representation above and replace the infinite sum by a finite one to obtain the Taylor series. The number of summands that one has to compute depends on the accuracy that is needed – although it is only an approximation, it serves its purpose in many applications.

The second approach to compute the exponential of a matrix in our project is diagonalization. At first the matrix $A$ is decomposed to a product of three matrices $Q$, $D$ and $Q^{-1}$,
$A= Q D Q^{-1}$,
where the columns of the matrix $Q$ contain the eigenvectors of $A$, the matrix $D$ is a diagonal matrix with the corresponding eigenvalues stored at the diagonal and $Q^{-1}$ is the inverse matrix of $Q$. With this decomposition, the computation of the matrix exponential is very easy because the following equality holds

$\exp(A)=Q \exp(D) Q^{-1}$.

The only expression that has not been calculated is $\exp(D)$ and this matrix is again a diagonal matrix with the exponential of the diagonal entries of $D$. If we multiply the matrices $Q$, $\exp(D)$ and $Q^{-1}$, we obtain the matrix exponential of $A$.

But this is not HPC, right?

Wait and see…