def invhilbert(n, exact=False):
 from scipy.special import comb
 if exact:
  if (n > 14):
   dtype = object
  else:
   dtype = np.int64
 else:
  dtype = np.float64
 invh = np.empty((n, n), dtype=dtype)
 for i in xrange(n):
  for j in xrange(0, (i + 1)):
   s = (i + j)
   invh[(i, j)] = ((((((-1) ** s) * (s + 1)) * comb((n + i), ((n - j) - 1), exact)) * comb((n + j), ((n - i) - 1), exact)) * (comb(s, i, exact) ** 2))
   if (i != j):
    invh[(j, i)] = invh[(i, j)]
 return invh

def invhilbert ( n , exact = False ) : from scipy . special import comb if exact : if ( n > 14 ) : dtype = object else : dtype = np . int64 else : dtype = np . float64 invh = np . empty ( ( n , n ) , dtype = dtype ) for i in xrange ( n ) : for j in xrange ( 0 , ( i + 1 ) ) : s = ( i + j ) invh [ ( i , j ) ] = ( ( ( ( ( ( - 1 ) ** s ) * ( s + 1 ) ) * comb ( ( n + i ) , ( ( n - j ) - 1 ) , exact ) ) * comb ( ( n + j ) , ( ( n - i ) - 1 ) , exact ) ) * ( comb ( s , i , exact ) ** 2 ) ) if ( i != j ) : invh [ ( j , i ) ] = invh [ ( i , j ) ] return invh
compute the inverse of the hilbert matrix of order n .