Skip to content

math: handle extreme orders in Jn and Yn - #81573

Open
cristiangirlea wants to merge 2 commits into
golang:masterfrom
cristiangirlea:fix-math-bessel-extreme-orders
Open

cristiangirlea wants to merge 2 commits into
golang:masterfrom
cristiangirlea:fix-math-bessel-extreme-orders

Conversation

@cristiangirlea

Copy link
Copy Markdown
Contributor

Use unsigned order magnitudes so MinInt can be represented, and convert
recurrence coefficients to float64 before doubling them.

Stop the backward recurrence when its scaling factor underflows, keeping
the sign implied by the order and argument. This avoids an impractically
long recurrence for inputs such as Jn(MaxInt, 1).

Add tests for extreme orders, signs, special values, subnormal results,
and large arguments where the result must not be forced to zero.
The existing recurrence is retained; enormous orders near the argument
can still require time proportional to the order.

The reported cases fail or time out before the fix and pass afterward.
Tests pass for math/..., with race and linux/386 checks for math.
A differential probe preserves 15,352 sampled outputs, and a separate
rational-series calculation checks the subnormal reference values.
The complete Go repository test suite was not run for this change.

Fixes #81489

Use unsigned order magnitudes so MinInt can be represented, and convert
recurrence coefficients to float64 before doubling them.

Stop the backward recurrence when its scaling factor underflows, keeping
the sign implied by the order and argument. This avoids an impractically
long recurrence for inputs such as Jn(MaxInt, 1).

Add tests for extreme orders, signs, special values, subnormal results,
and large arguments where the result must not be forced to zero.

Fixes golang#81489
Rename nn to absN in Jn and Yn to make the unsigned absolute order
explicit. The type, arithmetic, control flow and tests are unchanged.

Updates golang#81489
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 2bd0f31) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/834144.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

math: Jn and Yn mishandle extreme orders

2 participants