Repository navigation
Compute the terms of the Ln series in the package's exponent range - #169
Open
shounakjoshi88-a11y wants to merge 1 commit into
Open
shounakjoshi88-a11y wants to merge 1 commit into
shounakjoshi88-a11y wants to merge 1 commit into
Conversation
The terms of the power series of Ln are much smaller than the result, so a term can be below the exponent range of the context. The series was computed in the caller's range, so such a term was subnormal, the trap fired, and the ErrDecimal made the later steps no-ops. The exit test reads the term, which is never divided again once the trap has fired, so it kept the value of 2n+1 and the loop never ended. Ln(0.95) with a precision of 10 and a MinExponent of -5 never returned. The series is now computed with the package's exponent range and without the traps that its intermediate results trip, and the conditions of the caller's context are applied to the result. The series loop also checks the error of the computation, like the iteration below it does, so that a failure ends the loop instead of spinning. The values are the ones Python's decimal gives for the same context.
Author
|
The The GDA conformance suite (
The new test fails on the unmodified tree, where the series never ends: and passes with the change. The values it checks are the ones Python's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lnnever returned for some inputs:Python's
decimalgives-0.05129329439for the same context, so the result is nowhere near the exponent range.The terms of the power series of
Lnare much smaller than the result:so a term can be below the exponent range of the context. The series was computed in the caller's range, so such a term was subnormal, the
Subnormaltrap fired, and theErrDecimalmade the later steps no-ops. The exit test then read a term that was never divided again:tmp4kept the value of2n+1, which is never aboveeps, so the loop never ended. The iteration below it has aned.Err()check and returns, which is why only the power series hung.The series is now computed with the package's exponent range, and without the traps that its intermediate results trip:
and the loop checks the error of the computation, like the iteration below it does:
The result is still rounded in the caller's context, so the conditions of that context are the ones that are reported.
The new test in
context_test.gocovers the inputs that hung, with the values Python'sdecimalgives for the same context:and the
Inexacttrap of the context is still honoured: the series converges and the trap fires on the result.The test fails on the unmodified tree, where the series never ends:
and passes with the change:
The GDA conformance suite (
TestGDA) is green as well.This is independent of #160, which replaces the iteration with a different algorithm: this change is about the exponent range the series is computed in, not about the rounding of the result.