Repository navigation
fix(ddx-core): divide a quotient's derivative by its denominator once - #96
Merged
Merged
Conversation
This was referenced Sep 29, 2026
alxmrs
force-pushed
the
fix/integer-cast
branch
from
October 3, 2026 01:55
690a6b0 to
bb147ef
Compare
alxmrs
force-pushed
the
fix/quotient-rule
branch
from
October 3, 2026 01:55
9c26454 to
52ee36e
Compare
Member
Author
|
😈🧪 Adversarial tester: ✅ approved for correctness. Reviewed at |
The v2 soak (#92) noted that with infinite values in the data, the quotient rule's (du·v - u·dv)/v² evaluates ∞/∞ = NaN where the partial's limit is 0; and with tiny values (1e-163) v² underflows. ddx now emits (du - (u/v)·dv)/v, dividing by v once through the quotient itself: the same number everywhere else, finite at v = ∞ whether or not v depends on the variable, and never squaring v. (Splitting it into du/v - u·dv/v² fixes the infinite case but not the tiny one, where two 1/v terms cancel to noise: u/sinh(u) differentiated to ±1e159 instead of about 0.) A denominator constant in the variable leaves just du/v, which is also shorter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CvszJhH8pn8H9G69wEPMU2
alxmrs
force-pushed
the
fix/quotient-rule
branch
from
October 3, 2026 02:16
52ee36e to
16ab8b2
Compare
Merged
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 the #87 PR. Found by the v2 soak (#92), which had to exempt infinite data because of it, and refined after a tiny-values soak.
The textbook quotient rule
(du·v - u·dv)/v²squaresv:v = ∞(a value in the data) it evaluates∞/∞ = NaNwhere the limit is 0;v(1e-163)v²underflows to 0.ddx now emits
(du - (u/v)·dv)/v, which divides byvonce, through the quotient itself. That's the same number everywhere else, finite atv = ∞, and it never squaresv.I first tried splitting it into
du/v - u·dv/v². That handlesv = ∞, but at a tinyvits two1/vterms cancel to noise:u/sinh(u)differentiated to ±1e159 instead of about 0. When the denominator doesn't depend on the variable, the result is justdu/v.Rendered derivatives change accordingly:
d/dx x/yisCAST(1.0 AS DOUBLE) / y. The JAX oracle suites (137 tests), ddxdb's tests, and a 5-minute soak (227k cases) pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01CvszJhH8pn8H9G69wEPMU2