Condition Numbers

These are scratch notes for class, need to be turned into a proper lecture.

Quick illustration on condition number, based on these lecture notes.

For a thorough explanation, see this page.

In [1]:
import numpy as np
import scipy.linalg as la

h2 = la.hilbert(2)
h2
Out[1]:
array([[1.        , 0.5       ],
       [0.5       , 0.33333333]])
In [2]:
np.linalg.cond(h2)
Out[2]:
19.28147006790397
In [3]:
A = np.array([[ 1.2969, 0.8648 ],[ .2161, .1441]])
A
Out[3]:
array([[1.2969, 0.8648],
       [0.2161, 0.1441]])
In [4]:
np.linalg.cond(A)
Out[4]:
249729266.53363755
In [5]:
np.linalg.det(h2)
Out[5]:
0.08333333333333333
In [6]:
np.linalg.det(A)
Out[6]:
9.999999984453023e-09
In [7]:
np.linalg.inv(A)
Out[7]:
array([[ 1.44100000e+07, -8.64800001e+07],
       [-2.16100000e+07,  1.29690000e+08]])