# 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!

edit retag close merge delete

Sort by » oldest newest most voted

Yes, 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.

more

I assume this method only exists for matrices over "inexact rings", correct?

( 2017-02-09 15:28:51 -0500 )edit
1

@kcrisman that's accurate: both in RDF and CDF it exists, but not in ZZ, RR, QQ.

( 2017-02-09 15:39:22 -0500 )edit
1

Thanks! This helps--also with the random_matrix command that I didn't ask about!

Best to you!

( 2017-02-09 17:03:18 -0500 )edit