Question: I have a question, which might also fit on stackoverflow, but due to I think I made some mistake in my mathematical considerations I think math.stackexchange is more proper for my question.

Currently I'm writing a (python) program, where a small part of it deals with matrix logarithms. Due to I'm looking for a mistake, I could locate the error in the program part, which does the matrix logarithm. While looking where exactly the error might be, I got quite unsure whether my notion about matrix logarithm is correct.

For testing purposes I calculate the matrix logarithm by using scipy.linalg.logm() and some matrices, which are derived from random matrices. To ensure, that the input has full rank, I add $\delta \cdot \mathbf{1}$ for some little $\delta > 0$. 
Although I insert a real matrix $M$, most of the time $logm(M)$ is complex valued. The complex values don't seem to be numerical artefacts, since their magnitude is the same as the magnitude of the real values.

My question now is, whether it can be correct, that real matrices have complex logarithms?

On the one hand I know, that logm uses approximations, since not all matrices are can be diagonalized. According to the sourcecode logm uses techniques from Nicholas J. Higham's "Functions of Matrices: Theory and Computation", so (beside the fact, that scipy is tested quite well) I think the algorithm works correctly.

On the other hand both ways of calculating matrix logarithm I know about (diagonalizing and power series, which both of course don't work in all cases) give real logarithms for real matrices. So, since complex logarithms for real matrices don't occur in this cases, I cannot imagine whether such a result might be correct.

Does anyone have some argument which can confirm or deny my concerns?
Or do I have to look for the problem in the program code, as my cosiderations are correct?

Thanks in advance!

Answer: 
Well, a quick search revealed the following answer (from [Wikipedia](https://en.wikipedia.org/wiki/Logarithm_of_a_matrix)):

> 
> The answer is more involved in the real setting. **A real matrix has a real logarithm if and only if it is invertible and each Jordan block belonging to a negative eigenvalue occurs an even number of times.** If an invertible real matrix does not satisfy the condition with the Jordan blocks, then it has only non-real logarithms. This can already be seen in the scalar case: no branch of the logarithm can be real at -1. The existence of real matrix logarithms of real 2×2 matrices is considered in a later section.
> 
> 
> 

You should check if in your case you verify the property underlined above.
It's clear that the logarithm of a real matrix *can* be complex; for example if $A=[-1]$ then $\log A=[\log -1]$. For equally simple $n\times n$ examples with $n>1$ consider diagonal matrices...