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.Thu, 09 Feb 2017 17:03:18 -0600condition number of a matrixhttp://ask.sagemath.org/question/36511/condition-number-of-a-matrix/ I am a novice Sage user, trying to get my Linear Algebra students to use Sage, too. One part of a problem I have assigned in the past asks a student to find the condition number of a matrix. In Maple, the command is just ConditionNumber(A), where A is a defined matrix. Is there a similar command in Sage?
Thanks for any help!Thu, 09 Feb 2017 13:26:31 -0600http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/Answer by mforets for <p>I am a novice Sage user, trying to get my Linear Algebra students to use Sage, too. One part of a problem I have assigned in the past asks a student to find the condition number of a matrix. In Maple, the command is just ConditionNumber(A), where A is a defined matrix. Is there a similar command in Sage?</p>
<p>Thanks for any help!</p>
http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?answer=36513#post-id-36513Yes, check the method `condition`, as in:
A = random_matrix(RDF, 4)
A.condition(p=2) # produces the 2-norm (spectral norm) condition number
15.7271056154
sv = A.singular_values();
max(sv)/min(sv) # to check
15.7271056154
Type `A.condition?` for further examples.
Thu, 09 Feb 2017 13:54:05 -0600http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?answer=36513#post-id-36513Comment by srobbert for <p>Yes, check the method <code>condition</code>, as in: </p>
<pre><code>A = random_matrix(RDF, 4)
A.condition(p=2) # produces the 2-norm (spectral norm) condition number
15.7271056154
sv = A.singular_values();
max(sv)/min(sv) # to check
15.7271056154
</code></pre>
<p>Type <code>A.condition?</code> for further examples.</p>
http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36525#post-id-36525Thanks! This helps--also with the random_matrix command that I didn't ask about!
Best to you!Thu, 09 Feb 2017 17:03:18 -0600http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36525#post-id-36525Comment by mforets for <p>Yes, check the method <code>condition</code>, as in: </p>
<pre><code>A = random_matrix(RDF, 4)
A.condition(p=2) # produces the 2-norm (spectral norm) condition number
15.7271056154
sv = A.singular_values();
max(sv)/min(sv) # to check
15.7271056154
</code></pre>
<p>Type <code>A.condition?</code> for further examples.</p>
http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36520#post-id-36520@kcrisman that's accurate: both in `RDF` and `CDF` it exists, but not in `ZZ`, `RR`, `QQ`.Thu, 09 Feb 2017 15:39:22 -0600http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36520#post-id-36520Comment by kcrisman for <p>Yes, check the method <code>condition</code>, as in: </p>
<pre><code>A = random_matrix(RDF, 4)
A.condition(p=2) # produces the 2-norm (spectral norm) condition number
15.7271056154
sv = A.singular_values();
max(sv)/min(sv) # to check
15.7271056154
</code></pre>
<p>Type <code>A.condition?</code> for further examples.</p>
http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36519#post-id-36519I assume this method only exists for matrices over "inexact rings", correct?Thu, 09 Feb 2017 15:28:51 -0600http://ask.sagemath.org/question/36511/condition-number-of-a-matrix/?comment=36519#post-id-36519