Skip to content
Permalink
67ddcc4b49
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
32 lines (28 sloc) 702 Bytes
from scipy.linalg import inv, hilbert, invhilbert
import numpy as np
print("Inverse Hilbert Matrix n = 3: ")
print(invhilbert(3),True)
print("Inverse Hilbert Matrix n = 4: ")
print(invhilbert(4,True))
print("Inverse Hilbert Matrix n = 5: ")
print(invhilbert(5,True))
def HilbertApprox(n,m):
h = hilbert(n)
h = h.round(m)
# for i in h:
# for j in i:
# j = round(j,m)
# j = round(j,m)
# [round(i,m) for i in h[0]]
print("For H(", n, ") rounded to ", m, "decimal places:")
print(inv(h).round(m))
HilbertApprox(3,2)
HilbertApprox(4,2)
HilbertApprox(5,2)
HilbertApprox(3,1)
HilbertApprox(4,1)
HilbertApprox(5,1)
#print(type(hilbert(2)))
#a = [1,3.004,5.2222]
#[round(i,2) for i in a]
#print(a)