def _newton(n, x_initial, maxit=5):
 mu = sqrt(((2.0 * n) + 1.0))
 t = (x_initial / mu)
 theta = arccos(t)
 for i in range(maxit):
  (u, ud) = _pbcf(n, theta)
  dtheta = (u / (((sqrt(2.0) * mu) * sin(theta)) * ud))
  theta = (theta + dtheta)
  if (max(abs(dtheta)) < 1e-14):
   break
 x = (mu * cos(theta))
 if ((n % 2) == 1):
  x[0] = 0.0
 w = (exp((- (x ** 2))) / (2.0 * (ud ** 2)))
 return (x, w)

def _newton ( n , x_initial , maxit = 5 ) : mu = sqrt ( ( ( 2.0 * n ) + 1.0 ) ) t = ( x_initial / mu ) theta = arccos ( t ) for i in range ( maxit ) : ( u , ud ) = _pbcf ( n , theta ) dtheta = ( u / ( ( ( sqrt ( 2.0 ) * mu ) * sin ( theta ) ) * ud ) ) theta = ( theta + dtheta ) if ( max ( abs ( dtheta ) ) < 1e-14 ) : break x = ( mu * cos ( theta ) ) if ( ( n % 2 ) == 1 ) : x [ 0 ] = 0.0 w = ( exp ( ( - ( x ** 2 ) ) ) / ( 2.0 * ( ud ** 2 ) ) ) return ( x , w )
newton iteration for polishing the asymptotic approximation to the zeros of the hermite polynomials .