# logarithm of a matrix base a matrix — $\mathbf{A}^x = \mathbf{B}$

I want to solve $\mathbf{A}^x = \mathbf{B}$ where $\mathbf{A}$ and $\mathbf{B}$ are both $n$-by-$n$ matrices and $x$ is real. I see that in general there may be no solutions, or multiple solutions.

I was trying to find the period of a discrete-time linear dynamical system, but now I'm interested in the equation itself.

By "solve" I mean, given the two matrices, how can I find $x$ using the linear algebra primitives that MATLAB has, for example. Or maybe there's a name for this equation.

edit maybe less generally $\mathbf{A}^x = \lambda \mathbf{I}$

-
You have to be rather lucky to find an $x$ for "random" $A$ and $B$. Just think about the degrees of freedom... – Fabian Jul 7 '12 at 17:18
What kind of values do $A$ and $B$ take? Do you know them exactly or only to finite precision? – Qiaochu Yuan Jul 7 '12 at 18:54

It is not clear what you mean by $A^x$ for $x$ irrational or even for $x$ not an integer. This is an issue already when $n = 1$; for example, what do you mean by $(-1)^{1/2}$? ( Which square root of $-1$?) What do you mean by $(-1)^{\pi}$?
One fix in the case $n = 1$ is to restrict to the case that $A, B$ are positive reals. The corresponding restriction for matrices is to restrict to the case that $A, B$ are positive-definite Hermitian matrices. In that case the spectral theorem guarantees that $A$ has an orthonormal basis of eigenvectors $e_1, ... e_n$ with positive real eigenvalues $\lambda_1, ... \lambda_n$, so you can define $A^x$ by requiring that $$A^x e_i = \lambda_i^x e_i$$
for all $i$. A necessary condition for the existence of a solution to $A^x = B$ is that $B$ also has eigenvectors $e_1, ... e_n$ (since this is true of $A^x$), and a necessary and sufficient condition is that its eigenvalues $\mu_1, ... \mu_n$ with respect to those eigenvectors satisfies $$\lambda_i^x = \mu_i$$
for all $i$.
This was long ago! Sorry. Yes, probably in my case, the right answer would have been to diagonalize both matrices (or perhaps use the SVD). If the the bases were the same, then there is a chance that the eigenvalues of $A$, after exponentiating by some integer, would equal the eigenvalues of $B$. It looks like what I was trying to do was find the period of the discrete-time linear time-invariant system. And so the approach would be to find $A=V^{-1}\Lambda V$ and the smallest integer $n$ such that $\Lambda^n = I$ – Gus Apr 23 '15 at 14:38