ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 02 Sep 2013 14:13:44 -0500Why does jordan_form not work over inexact rings?http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/Hi,
Given a matrix M with entries (variables) in SR, I needed to compute the transformation matrix to a jordan form of M.
I ended up copying the code in "jordan_form" and "_jordan_form_vector_in_difference" from "matrix2.pyx",
deleting the "if (base_ring is None and not self.base_ring().is_exact()) ..."
and replacing "evals = A.charpoly().roots()" by
eigenvects=A.eigenvectors_right()
evals=[(eigenvect[0],eigenvect[2]) for eigenvect in eigenvects]
So far it seems to work. Can this go wrong? Or could one just change the original code in matrix2.pyx, and allow inexact rings?
Thanks for your help!Wed, 28 Aug 2013 23:43:36 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/Answer by Lolina for <p>Hi,</p>
<p>Given a matrix M with entries (variables) in SR, I needed to compute the transformation matrix to a jordan form of M.</p>
<p>I ended up copying the code in "jordan_form" and "_jordan_form_vector_in_difference" from "matrix2.pyx",
deleting the "if (base_ring is None and not self.base_ring().is_exact()) ..."
and replacing "evals = A.charpoly().roots()" by</p>
<pre><code> eigenvects=A.eigenvectors_right()
evals=[(eigenvect[0],eigenvect[2]) for eigenvect in eigenvects]
</code></pre>
<p>So far it seems to work. Can this go wrong? Or could one just change the original code in matrix2.pyx, and allow inexact rings?</p>
<p>Thanks for your help!</p>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15407#post-id-15407Yes, it's the "right" result, so
[ d0 1 0 0]
[ 0 d0 1 0]
[ 0 0 d0 1]
[ 0 0 0 d0]
@nbruin: So you are saying that in general there shouldn't be a problem in my case?Mon, 02 Sep 2013 05:30:40 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15407#post-id-15407Comment by nbruin for <p>Yes, it's the "right" result, so</p>
<pre><code>[ d0 1 0 0]
[ 0 d0 1 0]
[ 0 0 d0 1]
[ 0 0 0 d0]
</code></pre>
<p><a href="/users/62/nbruin/">@nbruin</a>: So you are saying that in general there shouldn't be a problem in my case?</p>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17080#post-id-17080You managed to compute the correct answer, didn't you? It's just that you can't expect the general code to perform well on non-exact input, since numerical stability would have to be taken into account. And SR has elements that should be considered non-exact. If you have further design questions about sage, please send them to a discussion group such as sage-support or sage-devel. Asksage is an awkward forum for discussion.Mon, 02 Sep 2013 14:13:44 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17080#post-id-17080Answer by tmonteil for <p>Hi,</p>
<p>Given a matrix M with entries (variables) in SR, I needed to compute the transformation matrix to a jordan form of M.</p>
<p>I ended up copying the code in "jordan_form" and "_jordan_form_vector_in_difference" from "matrix2.pyx",
deleting the "if (base_ring is None and not self.base_ring().is_exact()) ..."
and replacing "evals = A.charpoly().roots()" by</p>
<pre><code> eigenvects=A.eigenvectors_right()
evals=[(eigenvect[0],eigenvect[2]) for eigenvect in eigenvects]
</code></pre>
<p>So far it seems to work. Can this go wrong? Or could one just change the original code in matrix2.pyx, and allow inexact rings?</p>
<p>Thanks for your help!</p>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15393#post-id-15393Please could you provide the entries of your matrix more precisely ?
You should notice that things like `x` or even `cos(x)` are elements of the
`Symbolic Ring`, and i doubt that your method will work correcly with such
entries. the `Symbolic Ring` also contains elements of `RR` for which the
computation of eigenvalues is not reliable.
Depending on your entries, it could make sense to send them to an exact ring
first (e.g. the algebraic numbers).
Also, if your entries are numerical, you should convert them in `RDF` for which the
computation of eigenvalues is OK.
Thu, 29 Aug 2013 05:03:15 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15393#post-id-15393Answer by tmonteil for <p>Hi,</p>
<p>Given a matrix M with entries (variables) in SR, I needed to compute the transformation matrix to a jordan form of M.</p>
<p>I ended up copying the code in "jordan_form" and "_jordan_form_vector_in_difference" from "matrix2.pyx",
deleting the "if (base_ring is None and not self.base_ring().is_exact()) ..."
and replacing "evals = A.charpoly().roots()" by</p>
<pre><code> eigenvects=A.eigenvectors_right()
evals=[(eigenvect[0],eigenvect[2]) for eigenvect in eigenvects]
</code></pre>
<p>So far it seems to work. Can this go wrong? Or could one just change the original code in matrix2.pyx, and allow inexact rings?</p>
<p>Thanks for your help!</p>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15401#post-id-15401I am curious to see what does Sage answers on this particular example. If there is no asumption on the `di`, the following non equivalent answers are possible:
[ d0 1 0 0]
[ 0 d0 1 0]
[ 0 0 d0 1]
[ 0 0 0 d0]
[ d0 0 0 0]
[ 0 d0 0 0]
[ 0 0 d0 0]
[ 0 0 0 d0]
Sun, 01 Sep 2013 02:18:03 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15401#post-id-15401Comment by nbruin for <p>I am curious to see what does Sage answers on this particular example. If there is no asumption on the <code>di</code>, the following non equivalent answers are possible:</p>
<pre><code>[ d0 1 0 0]
[ 0 d0 1 0]
[ 0 0 d0 1]
[ 0 0 0 d0]
[ d0 0 0 0]
[ 0 d0 0 0]
[ 0 0 d0 0]
[ 0 0 0 d0]
</code></pre>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17093#post-id-17093Actually, there is only one possibility. The matrix M-d0*I has a one-dim kernel if d1 is non-zero, so there's only one Jordan block.The symbolic ring has issues, but for simple polynomial algebra its properties are fairly regular: a variable like d1 is simply a transcendental element, so in particular non-zero. (SR tries to model a domain)Sun, 01 Sep 2013 09:32:32 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17093#post-id-17093Answer by Lolina for <p>Hi,</p>
<p>Given a matrix M with entries (variables) in SR, I needed to compute the transformation matrix to a jordan form of M.</p>
<p>I ended up copying the code in "jordan_form" and "_jordan_form_vector_in_difference" from "matrix2.pyx",
deleting the "if (base_ring is None and not self.base_ring().is_exact()) ..."
and replacing "evals = A.charpoly().roots()" by</p>
<pre><code> eigenvects=A.eigenvectors_right()
evals=[(eigenvect[0],eigenvect[2]) for eigenvect in eigenvects]
</code></pre>
<p>So far it seems to work. Can this go wrong? Or could one just change the original code in matrix2.pyx, and allow inexact rings?</p>
<p>Thanks for your help!</p>
http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15394#post-id-15394Thanks for the answer.
I want to compute [the transformation matrix to] the Jordan normal forms of block matrices whose blocks are of the form
[ d0 d1 d2 d3]
[ 0 d0 d1 d2]
[ 0 0 d0 d1]
[ 0 0 0 d0]
(i.e. an upper triangular Toeplitz matrix whose entries are variables or 0).
Thu, 29 Aug 2013 06:37:31 -0500http://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15394#post-id-15394