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.Mon, 02 Sep 2013 21:13:44 +0200Why does jordan_form not work over inexact rings?https://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!Thu, 29 Aug 2013 06:43:36 +0200https://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>
https://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 13:37:31 +0200https://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15394#post-id-15394Answer 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>
https://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 09:18:03 +0200https://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>
https://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 16:32:32 +0200https://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17093#post-id-17093Answer 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>
https://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 12:03:15 +0200https://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?answer=15393#post-id-15393Answer 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>
https://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 12:30:40 +0200https://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>
https://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 21:13:44 +0200https://ask.sagemath.org/question/10488/why-does-jordan_form-not-work-over-inexact-rings/?comment=17080#post-id-17080