fix: handle boundary cases for divide and log functions#3645
Closed
orelbn wants to merge 1 commit intojosdejong:developfrom
Closed
fix: handle boundary cases for divide and log functions#3645orelbn wants to merge 1 commit intojosdejong:developfrom
orelbn wants to merge 1 commit intojosdejong:developfrom
Conversation
Collaborator
|
@orelbn thank you so much for your interest and taking the time to generate a PR in an effort to address the long-standing issue #1277. However, the core of your PR consists of a "patch" to the behavior of Complex.js and we're not going to go down that path in math.js. If there is non-ideal behavior in Complex.js that is leading to this issue in mathjs, please file a report with Complex.js, and once the behavior is fixed there, we will update to the new release of Complex.js. Thanks! (and so closing this PR) |
Contributor
Author
|
No problem, thanks for the feedback! |
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.
Description
log(x, base)(log(x) / log(base)).Complex(Infinity, NaN)) for:Complex/Complexwith zero denominatornumber/numberwhen numerator is±Infinityand denominator is0-Infinity/0and complex divide-by-zero inconsistencies and proposing complex infinity style handling:Tests
test/unit-tests/function/arithmetic/divide.test.jstest/unit-tests/function/arithmetic/log.test.jslog(0, 1)log(-1, 1)log(-1, -1)log(0, 0)i/0,(1+i)/0,(1-i)/(0+0i).npx mocha test/unit-tests/function/arithmetic/log.test.js test/unit-tests/function/arithmetic/divide.test.jsBreaking Changes
Infinity + Infinity inow returnComplex(Infinity, NaN).±Infinity / 0now returnsComplex(Infinity, NaN)instead of numeric±Infinity.±Infinity / 0must adapt to Complex output in that boundary case.Impact on Codebase
Positive consistency impact
src/function/arithmetic/divideScalar.js, reducing duplicated special-case logic in higher-level functions.src/function/arithmetic/log.jsremains generic (divideScalar(self(x), self(base))), improving maintainability.Cross-function behavioral impact
Complex/Complexandnumber/number(±Infinity / 0) division now inherit normalized complex-infinity behavior.Testing impact
Risk profile
±Infinity / 0), not broad numerical regressions in finite-domain operations.