-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spurious underflow in kronrod for large n #93
Labels
Comments
Even with the rescaling, however, Laurie's algorithm seems to suffer from some severe accuracy issues in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As mentioned on discourse, the
kronrod
routine yields NaN for largern
, e.g.It looks like this is due to spurious underflow in the
_kronrodjacobi
function. It forms arrayss
andt
by calculations that involve repeatedly multiplying by theb
matrix, corresponding to the squared off-diagonal elements of the Jacobi matrix. For the canonical interval (-1,1) with a constant weight function, the entries of theb
matrix asymptote to 0.25, so this effectively divides by 4 over and over and eventually underflows.The underflow is spurious because the final Kronrod–Jacobi matrix only depends on ratios of
s
andt
entries, so we are free to rescale them by any overall constant factor that we want. This fact is actually mentioned in a somewhat obscure way by Laurie's paper:Rescaling the interval to (-2,2) works because it multiplies the integrals by 2, and hence the squared Jacobi matrix entries get multiplied by 4, causing
b
to asymptote to 1 and removing the exponential shrinkage.We could do the same trick, but it's not clear how to generalize this to arbitrary Jacobi matrices. Instead, it should suffice to normalize the
s
andt
matrices (e.g. scaling by their infinity norm) after each iteration. This should only slow things down by a small constant factor (1–2% in my current experiments).The text was updated successfully, but these errors were encountered: