A product is written letters before functions - #1635
Open
Rafael-SOWNet wants to merge 1 commit into
Open
Rafael-SOWNet wants to merge 1 commit into
Rafael-SOWNet wants to merge 1 commit into
Conversation
By hand a product is written the number first, then the letters and their powers, then the functions: y sin(x), x e^x, z Γ(z) (DLMF 5.5.1). ISO 80000-2 lets a function's argument go without parentheses, sin nπ, so a letter written after a function reads as part of its argument. Simplify wrote sin(x) * y and e ^ x * x, the order its search sorts by. The answer of Simplify is now put in that order as its last step, each kind of factor keeping the order it had, and a leading number is taken into a quotient over a number: 2 / s, not 2 * 1 / s. The search keeps its own order. Its product rules are binary and meet 2 cos(x) sin(x) as neighbours only because nothing sorts between them; sorting letters first inside the search stopped 2 x sin(x) cos(x) becoming x sin(2x) and made lim 1/x^2 - 1/sin(x)^2 at 0 NaN. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
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.
By hand, a product is written with the number first, then the letters and their powers, then the functions:
y sin(x),x e^x,z Γ(z)(DLMF 5.5.1). The reason is that a function's argument can be written without parentheses. ISO 80000-2 allowssin nπ, so a letter written after a function reads as part of its argument.Simplifywrotesin(x) * yande ^ x * x.The answer of
Simplifyis now put in that order as its last step (Simplificator.InPrintOrder): numbers, then letters and their powers, then everything else, each kind keeping the order it had.e^xand2^ncount as functions, andx^ncounts as a letter. A leading number goes into a quotient over a number, so the derivative ofarcsin(2 * x)simplifies to2 / sqrt(1 - (2 * x) ^ 2)rather than2 * 1 / sqrt(…).Only the answer is reordered. I first measured sorting letters first inside the search itself, and it lost four things:
lim 1/x^2 - 1/sin(x)^2at 0 becameNaN, where it is-1/3, and its two siblings stopped answering.x * (x - 1)!stopped becomingx!.The product rules are binary, and they meet
2 cos(x) sin(x)as neighbours only because the search's order sorts every function before every letter. Withxbetween them,2 x sin(x) cos(x)stopped becomingx sin(2x), and l'Hôpital's quotients grew past their guard. The numbers are on #1628. So the search keeps its order, andInnerSimplifiedandDifferentiatereturn that order as before.Simplifyofsin(x) * ysin(x) * yy * sin(x)x * e ^ xe ^ x * xx * e ^ x2 * sin(x) * y2 * sin(x) * y2 * y * sin(x)a / sin(x)csc(x) * aa * csc(x)2 * x * sin(x) * cos(x)sin(2 * x) * xx * sin(2 * x)derivative(arcsin(2 * x), x)1 / sqrt(1 - (2 * x) ^ 2) * 22 / sqrt(1 - (2 * x) ^ 2)FactorOrderTestcovers three things:TheRulesStillMeetTheFactorsTheyCombine:2 x sin(x) cos(x)→x sin(2x)andx (x - 1)!→x!. Both fail if the order is changed inside the search.Twenty-one existing expectations are updated to the new spelling. None of them changes value.
Suite on net10.0, at
405b4d2aon masterfac6ce16: 14202 passed, none failed. Every target framework builds.Gate: allocation matches the baseline on all 19 gated benchmarks. The step reads a product's order before building anything, and most answers are in order already.
Closes #1628.
Part of #180.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura