I am working with Hermite polynomials in Mathematica with the built-in function HermiteH. I want to compute the zeros of the polynomial HermiteH[N,x] for N as large as I can, as I am computing a Gaussian quadrature rule for integration of a smooth function.
I observe that, as N increases, the accuracy of NSolve drops dramatically. For instance,
HermiteH[18, x /. NSolve[HermiteH[18, x] == 0, x, Reals]]
{1., -0.28125, -0.0175781, -0.000732422, 0.000366211, -0.0000686646, 0.0000267029,
9.53674*10^-7, 2.6226*10^-6, 2.6226*10^-6, 9.53674*10^-7, 0.0000267029, -0.0000686646,
0.000366211, -0.000732422, -0.0175781, -0.28125, 1.}
You see, Hermite[18, x] evaluates at the first root as 1. Is there any way to improve the accuracy? Is there any built-in function to compute the roots of Hermite polynomials? Thank you for your help.
Solveinstead ofNSolve? Or add aWorkingPrecisionoption? – Carl Woll Jun 28 '19 at 19:56N, as this will use machine numbers, and you will lose lots of precision due to subtractive cancellation. – Carl Woll Jun 28 '19 at 20:05NSolveseems to have found in each case the numberxsuch thatAbs[Hermite[18, x]]is as small as possible in a small neighborhood ofx. Keep in mind that floating-point numbers are discrete. When the derivative of a function is large, as it is especially at the extreme roots, the difference between function values at adjacent floating-point numbers can seem large. The error in the residual should be bounded byD[HermiteH[18, x], x] x $MachineEpsilon/2 /. {x -> x0}, wherex0is a root found byNSolve. – Michael E2 Jun 29 '19 at 04:48