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, 08 Sep 2014 21:46:20 +0200How to plot the output of A.eigenvectors_right()?https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/ Trying to calculate and plot eigenvectors of a matrix A.
The call A.eigenvectors_right() works, but the output is a mixed list. How to extract the
eigenvectors from it to plot them?
The attempt: s=Lambda.eigenvectors_right();v=s[1];v[1];v1=v[1];plot(v1) gives
an error message...
Thank you. Mon, 08 Sep 2014 06:06:34 +0200https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/Answer by tmonteil for <p>Trying to calculate and plot eigenvectors of a matrix A.
The call A.eigenvectors_right() works, but the output is a mixed list. How to extract the
eigenvectors from it to plot them?
The attempt: s=Lambda.eigenvectors_right();v=s[1];v[1];v1=v[1];plot(v1) gives
an error message...
Thank you. </p>
https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?answer=24044#post-id-24044As you can see, ``v1`` is a list containing a single tuple:
sage: v1
[(1, 1.618033988749895?)]
You want to plot the vector described by the inner tuple, not the list. The following should work:
sage: plot(v1[0])
Mon, 08 Sep 2014 10:57:01 +0200https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?answer=24044#post-id-24044Comment by DVD for <p>As you can see, <code>v1</code> is a list containing a single tuple:</p>
<pre><code>sage: v1
[(1, 1.618033988749895?)]
</code></pre>
<p>You want to plot the vector described by the inner tuple, not the list. The following should work:</p>
<pre><code>sage: plot(v1[0])
</code></pre>
https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?comment=24063#post-id-24063Looks like "flatten()" is needed (see below)...Mon, 08 Sep 2014 21:44:47 +0200https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?comment=24063#post-id-24063Answer by FrédéricC for <p>Trying to calculate and plot eigenvectors of a matrix A.
The call A.eigenvectors_right() works, but the output is a mixed list. How to extract the
eigenvectors from it to plot them?
The attempt: s=Lambda.eigenvectors_right();v=s[1];v[1];v1=v[1];plot(v1) gives
an error message...
Thank you. </p>
https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?answer=24043#post-id-24043Something like that maybe ?
sage: A = matrix([[2, 3], [3, 5]])
sage: l = flatten([u[1] for u in A.eigenvectors_right()])
sage: add(plot(v) for v in l)Mon, 08 Sep 2014 09:22:59 +0200https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?answer=24043#post-id-24043Comment by DVD for <p>Something like that maybe ?</p>
<pre><code>sage: A = matrix([[2, 3], [3, 5]])
sage: l = flatten([u[1] for u in A.eigenvectors_right()])
sage: add(plot(v) for v in l)
</code></pre>
https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?comment=24064#post-id-24064It works!...Mon, 08 Sep 2014 21:46:20 +0200https://ask.sagemath.org/question/24042/how-to-plot-the-output-of-aeigenvectors_right/?comment=24064#post-id-24064