All problems
Hilbert 2x2 Condition Number
Problem
Return the 2-norm condition number of the n x n Hilbert matrix, for n = 1 or 2.
For n = 2, the matrix [[1, 1/2], [1/2, 1/3]] is symmetric positive definite with eigenvalues (4 +/- sqrt(13)) / 6, so the condition number is their ratio. Return None for any other n.
Hint
For a symmetric positive definite matrix, the 2-norm condition number is the ratio of extreme eigenvalues.
Test cases
case 1
in: [1]
expected: 1
case 2
in: [2]
expected: 19.281470067903985
case 3
in: [0]
expected: null
case 4
in: [3]
expected: null
Starter codePython
def hilbert_condition(n):
# Your code here
pass4 test cases · run your code against them in the editor