Repository navigation
Log: a zero value gets the error of x, as in WMA - #2067
Open
tombouctou wants to merge 2 commits into
Open
tombouctou wants to merge 2 commits into
tombouctou wants to merge 2 commits into
Conversation
MATH-257, the rest of #2047 step 6 for complex numbers. - Precision of a Complex is its accuracy (the parts' errors in quadrature) plus Log10 of its modulus, to which an exact part counts. - Plus and Times on Complex numbers with exact or PrecisionReal parts work out each part from the real rules. Times multiplies as a balanced tree and squares a pair of the same number, z^n squares from the top bit of n, and 1/z is (a - b I)/(a^2 + b^2), as WMA does. 2.`20 I keeps an exact zero real part. - A function with a complex value at real arguments (ArcSin[2.`20], Log[-1.`20], ArcCosh[0``20], ...) gives each part the error from that part of x f'[x]; a part that does not change gets 2^-54 of the error. - A negative PrecisionReal to a Rational power: x^(1/q) shares the error of the whole between its parts; x^(p/q) is x^n (x^(1/q))^r. - Log[x] no longer becomes Log[E, x], whose base added an error. - A Complex shows an inexact zero real part; N[I, 30] is 1.`30 I. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MATH-258. Log[1.`20] is 0``20. and Log[b, 1.`20] is 0 with the accuracy of x plus Log10[Abs[Log[b]]], as in WMA: the change of f within the error of each argument, the others held fixed, added up. The base does not change a zero, so Log[2.`20, 1.`25] is 0``24.84. - A base that is 1, or whose error covers 1, gives ComplexInfinity, and Indeterminate when x is or covers 1 too; these raised ZeroDivisionError. An inexact 0 gives Indeterminate, and Log[b, 1] with an exact 1 is an exact 0. - The change within an error is the leading term c delta^p of f, as in WMA, so Log[1.`3] is 0``3. and Sin[0``1.5] is 0``1.5 rather than showing the next terms. - MPMathFunction.special_point_value takes the Indeterminate check of indeterminate_at, and Log adds its own points there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
@tombouctou: I'd be grateful if you would handle the merge conflicts. Thanks! |
This branch has not been deployed
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.
Stacked on #2066 (base
complex-precision), which already reworksLog. Once #2066 merges, this PR's base moves to master.In WMA, when the value of a function is 0, its error is the change of
fwithin the error of each argument, with the other arguments held fixed, and these changes are summed. SoLog[1.`20]is020., andLog[b, 1.20]`` has accuracyP + Log10[Abs[Log[b]]]: ``Log[2, 1.20]is019.84andLog10[1.`20]is020.36. The error of the base does not change a zero value:Log[2.20, 1.25]`` has accuracy 24.8408.c δ^pat the size of the error, as in WMA. The step is measured atδ 2^-40and at half of that, andpis rounded to a multiple of 1/2. Before this PR the change was measured at the error itself, which is wrong at low precision. This fixes other functions too:Sin[01.5]now has accuracy 1.5 (it was 1.50007),Cos[02]4.30103,ArcCos[1.`3]1.34949 andLog[1.`3]3. The test value forAccuracy[ArcCos[1.`5]]changes from 2.34948 to 2.34949, which is what WMA gives.Log. Before this PR,Log[1.`20, 1.`20]raisedZeroDivisionErrorinside mpmath, on master as well. Now, as in WMA:Indeterminate;1.included), givesComplexInfinity, orIndeterminatewhenxis or covers 1 too;x = 1with any other base gives an exact0:Log[2.`20, 1]is0.MPMathFunction.special_point_valuetakes over the oldindeterminate_atcheck, so a function can name its own special values;Logoverrides it.Tests are in
test_log_zero_precision, next totest_real_valued_precision, and all the values come from WMA 15.Left for later, as before this PR:
Log[1.`20 + 020 I]andLog[-1.20, 1.20]``;Log[2.`20, 1.00000000000000000001`20], because the parser stores slightly different bits than WMA;Log[1.`0.5], because of the sharedprecision < 1guard;Powerof an inexact zero (Log[2, 1.`20]^2,Sqrt[03]``).Locally,
test_numbers.py,test/builtin/numbers,test/evaland the special-function tests give 1180 passed and 1 xfailed. black, isort and mypy report nothing.🤖 Generated with Claude Code