def gauss_hermite(n, n_digits):
 x = Dummy('x')
 p = hermite_poly(n, x, polys=True)
 p1 = hermite_poly((n - 1), x, polys=True)
 xi = []
 w = []
 for r in p.real_roots():
  if isinstance(r, RootOf):
   r = r.eval_rational((S(1) / (10 ** (n_digits + 2))))
  xi.append(r.n(n_digits))
  w.append(((((2 ** (n - 1)) * factorial(n)) * sqrt(pi)) / ((n ** 2) * (p1.subs(x, r) ** 2))).n(n_digits))
 return (xi, w)

def gauss_hermite ( n , n_digits ) : x = Dummy ( 'x' ) p = hermite_poly ( n , x , polys = True ) p1 = hermite_poly ( ( n - 1 ) , x , polys = True ) xi = [ ] w = [ ] for r in p . real_roots ( ) : if isinstance ( r , RootOf ) : r = r . eval_rational ( ( S ( 1 ) / ( 10 ** ( n_digits + 2 ) ) ) ) xi . append ( r . n ( n_digits ) ) w . append ( ( ( ( ( 2 ** ( n - 1 ) ) * factorial ( n ) ) * sqrt ( pi ) ) / ( ( n ** 2 ) * ( p1 . subs ( x , r ) ** 2 ) ) ) . n ( n_digits ) ) return ( xi , w )
computes the gauss-hermite quadrature [1]_ points and weights .