Ask Your Question
1

Imaginary matrix exponential

asked 2014-08-14 17:34:04 +0100

wpunkt gravatar image

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 flag offensive close merge delete

Comments

1

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

FrédéricC gravatar imageFrédéricC ( 2014-08-30 11:18:05 +0100 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2014-08-14 18:52:59 +0100

kcrisman gravatar image

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.

edit flag offensive delete link more
1

answered 2014-08-30 07:48:23 +0100

rws gravatar image

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]

See http://sagemath.org/doc/reference/num...

edit flag offensive delete link more
1

answered 2014-08-30 00:09:11 +0100

tmonteil gravatar image

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]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-14 17:34:04 +0100

Seen: 1,006 times

Last updated: Aug 30 '14