# Imaginary matrix exponential

Is there a way sage can evaluate this?

A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]]) e^(i*A)

TypeError: ECL says: Error executing code in Maxima: Unable to find the spectral representation

I was hoping that using the Complex Double Field would help. But it didn't.

edit retag close merge delete

You can use A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]]); (CDF(I)*A).exp()

( 2014-08-30 11:18:05 +0200 )edit

Sort by » oldest newest most voted

Instead of symbolic I use QQbar(I):

sage: A = Matrix(CDF, [[1,2,3],[3,2,0],[1,2,1]])
sage: C=QQbar(I)*A
sage: C.exp()
[  0.651747342998 - 1.54379760025*I -0.732155536636 - 0.455927080561*I   0.599292752801 + 1.47303558858*I]
[ 0.174911238362 + 0.933804036222*I   1.13443260356 - 0.693298035819*I   -1.27314454332 - 1.61769465706*I]
[ -0.648998777944 - 0.58745124185*I -0.166313517385 + 0.263048322578*I   1.50051037188 - 0.465334495539*I]

more

The problem is indeed the use of Maxima, through the evil Symbolic Ring. If you look at its source code:

sage: A = Matrix(CDF, [[1,2,3],[3,2,0],[1,2,1]])
sage: C = I*A
sage: C.exp??


You will see that it always use Maxima, even if you replace CDF by RDF, RR, QQ or ZZ. The reason is that all those C are matrices are defined over the the Symbolic Ring, because of the coercion with the number I which is unfortunately symbolic by default:

sage: A.parent()
Full MatrixSpace of 3 by 3 dense matrices over Complex Double Field
sage: C.parent()
Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring


So if you want to take the benefits of scipy, you should put C back into a good ring:

sage: D = C.change_ring(CDF)
sage: D.exp()
[  0.651747342998 - 1.54379760025*I -0.732155536636 - 0.455927080561*I   0.599292752801 + 1.47303558858*I]
[ 0.174911238362 + 0.933804036222*I   1.13443260356 - 0.693298035819*I   -1.27314454332 - 1.61769465706*I]
[ -0.648998777944 - 0.58745124185*I -0.166313517385 + 0.263048322578*I   1.50051037188 - 0.465334495539*I]

more

No, it doesn't help because it is still calculated in Maxima using eigenvalues, I believe. See the discussion at Trac 13973 for several workarounds, including one that we include that apparently doesn't fix all cases. Apparently your example never did work in Maxima, for reasons that may have to do with theoretical properties of the particular matrix, I am not sure.

more