Repository navigation
A logarithm to base 0 has no value - #2258
Open
Rafael-SOWNet wants to merge 2 commits into
Open
Rafael-SOWNet wants to merge 2 commits into
Rafael-SOWNet wants to merge 2 commits into
Conversation
log(0, 2) evaluated to 0, and log(x, 2) compiled to (-0, -0) at 0. Both took it as ln(x) / ln(0), which is ln(x) / (-oo). But 0 is not a base, since no power of it is anything but 0, and Logf's condition already excluded it: not x = 0 and not x = 1. Number.Log, ComplexBranches.Log and the LINQ compiler's double and float Log now answer an exact zero base with NaN. Over double, Math.Log already gave NaN, except for an antilogarithm of 1, where it gave -0. A base that is small but not 0 keeps its logarithm, so the test is for an exact zero, not IsZero's tolerance. LogarithmToBaseZeroTest takes six logarithms to base 0, evaluated and simplified, and four compiled by FastExpression, the LINQ compiler over Complex and over double. Seven fail on master. Three logarithms to other bases pin what has not changed, 10^(-100) among them. Found by work/domaincheck. Fixes #2255. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2258 +/- ##
=======================================
Coverage 86.71% 86.72%
=======================================
Files 310 310
Lines 67790 67799 +9
Branches 19666 19670 +4
=======================================
+ Hits 58786 58796 +10
+ Misses 4892 4891 -1
Partials 4112 4112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
log(b, 1) simplified to 0 provided not b = 1, which is 0 at b = 0. With log(0, 1) now NaN, BoundCheck found that disagreement, and the fold now provides not b = 0 as well, as log's condition does. TheLogarithmOfOneExcludesTheBase0 takes the simplification at 0, 1 and 2. BoundCheck has 0 disagreements again. Part of #2255. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
log(0, x)evaluated to0for a positivex, and compiled to(-0, -0). Both took it asln(x) / ln(0), which isln(x) / (-oo). But 0 is not a base: no power of it is anything but 0, andLogf's own condition already excluded it. An exact zero base is nowNaNinNumber.Log,ComplexBranches.Logand the LINQ compiler'sdoubleandfloatLog. A base that is small but not 0 keeps its logarithm, so the check is for an exact zero, notIsZero's tolerance."log(0, 2)".ToEntity().Evaled00NaN"log(0, 1)".ToEntity().Evaled0NaN"log(x, 2)".ToEntity().Compile("x").Call(0)(-0, -0)(-0, 0)(NaN, 0)Over
double,Math.Logalready gaveNaNexcept for an antilogarithm of 1, where it gave-0.The second commit is from BoundCheck in CI.
log(b, 1)simplified to0 provided not b = 1, which is 0 atb = 0. It now providesnot b = 0as well, aslog's condition does, and BoundCheck has 0 disagreements again.LogarithmToBaseZeroTest: seven cases fail on master, and six pass on both (three are logarithms to other bases). Suite 18185 passed. The F# wrapper suite, the Mcp, Terminal and InteractiveWrapper suites and the AOT smoke test pass. Found bywork/domaincheck.Fixes #2255.
🤖 Generated with Claude Code