ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 30 Aug 2014 11:18:05 +0200Imaginary matrix exponentialhttps://ask.sagemath.org/question/23784/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.Thu, 14 Aug 2014 17:34:04 +0200https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/Comment by FrédéricC for <p>Is there a way sage can evaluate this?</p>
<p>A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]])
e^(i*A)</p>
<p>TypeError: ECL says: Error executing code in Maxima: Unable to find the
spectral representation</p>
<p>I was hoping that using the Complex Double Field would help. But it didn't.</p>
https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?comment=24003#post-id-24003You can use A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]]); (CDF(I)*A).exp()Sat, 30 Aug 2014 11:18:05 +0200https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?comment=24003#post-id-24003Answer by kcrisman for <p>Is there a way sage can evaluate this?</p>
<p>A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]])
e^(i*A)</p>
<p>TypeError: ECL says: Error executing code in Maxima: Unable to find the
spectral representation</p>
<p>I was hoping that using the Complex Double Field would help. But it didn't.</p>
https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=23788#post-id-23788No, it doesn't help because it is still calculated in Maxima using eigenvalues, I believe. See the discussion at [Trac 13973](http://trac.sagemath.org/ticket/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.Thu, 14 Aug 2014 18:52:59 +0200https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=23788#post-id-23788Answer by rws for <p>Is there a way sage can evaluate this?</p>
<p>A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]])
e^(i*A)</p>
<p>TypeError: ECL says: Error executing code in Maxima: Unable to find the
spectral representation</p>
<p>I was hoping that using the Complex Double Field would help. But it didn't.</p>
https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=24001#post-id-24001Instead 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/number_fields/sage/rings/qqbar.html
Sat, 30 Aug 2014 07:48:23 +0200https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=24001#post-id-24001Answer by tmonteil for <p>Is there a way sage can evaluate this?</p>
<p>A = Matrix(CDF,[[1,2,3.],[3,2,0],[1,2,1]])
e^(i*A)</p>
<p>TypeError: ECL says: Error executing code in Maxima: Unable to find the
spectral representation</p>
<p>I was hoping that using the Complex Double Field would help. But it didn't.</p>
https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=23997#post-id-23997The 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]
Sat, 30 Aug 2014 00:09:11 +0200https://ask.sagemath.org/question/23784/imaginary-matrix-exponential/?answer=23997#post-id-23997