Repository navigation
The solver tries the equation as written before asking for its alternatives: SolveHard -98.6% allocation - #1209
Merged
Merged
Conversation
…atives: SolveHard -98.6% allocation Attributing SolveHard's 859 MB to the stages of AnalyticalEquationSolver with a temporary hook found two things done before any solving: - The replacement machinery asked Entity.Alternate(4) -- a whole level-4 simplification of the equation, the search Simplify runs -- for every spelling before trying any, at every depth of its own recursion, and in the ordinary case solved the first spelling it got, which was the equation itself. 268 MB of the top-level call and a third of each level below. SpellingsToSolveOver now yields the equation as it stands and builds the alternatives only if it is reached past that. A spelling that comes back as a condition rather than a finite set is kept as a fallback and the next spelling tried, which keeps x^4 * x^y - 2 answered with a root. - TryGetRationalCoefficients expanded the whole equation -- huge radical constants included -- before discovering that a sine is not a monomial, twice per equation visited (the rational-root split and the factoring gate). It reads the tree first now: x only under sums, products, quotients by something free of it and whole powers, and no symbol or constant in a coefficient. Measured by the gate on one machine: SolveHard 859,268,416 -> 11,818,936 B and 700 -> 109 ms; SolveMediumHard 94,415,256 -> 1,435,934 B and 66.8 -> 13.9 ms; SolveMedium -32%, SolveEasyMedium -33%; SimplifyHard -7.2% and SimplifyEasy -5.4% through the same pre-check. The baseline moves with it. Every solve in the suite answers as before but one, whose condition's terms come in the order the equation had; BREAKING-CHANGES.md has the row. Part of #746. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
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.
Part of #746 — the standing condition on speed. Same method as #1205 and #1207: a temporary hook attributing allocated bytes to the stages of
AnalyticalEquationSolver.Solve, per recursion depth, run onSolveHard.What the attribution showed
Entity.Alternate(4)before the replacement loop, top levelTrySplitOffRationalRoots+IsWorthFactoringToSolveWhat changes
SpellingsToSolveOveryields the equation, then the alternatives — and builds them only if the loop gets that far. A spelling that comes back as a condition rather than a finite set is kept as a fallback while the next spelling is tried; that is what keepsx^4 * x^y - 2answered with a root (SolveOneEquation.ExpSimplcaught the first version).TryGetRationalCoefficientsreads the tree before it expands.xonly under sums, products, quotients by something free of it, and whole non-negative powers; no symbol or constant in a coefficient. A necessary condition only — what passes it is still expanded and checked — so it can lose nothing but time.Measured
Gate on one machine, both columns in one session:
e45413c2)SolveHardSolveMediumHardSolveMediumSolveEasyMediumSimplifyHardSimplifyEasyEvery other entry within 0.1%. The gate's baseline is updated in the same change. Since the 1930th column this morning:
SolveHard−99.2%,SolveMediumHard−99.1%,SimplifyHard−81%.Answers
Every solve in the suite answers as before but one:
(x - b)/(x + a) + c/(x + a)keeps its root, and the condition on it is spellednot -(-b + c) + a = 0where it wasnot a + -(-b + c) = 0— the terms in the order the equation had, since it is solved as written rather than resimplified first. Re-pinned with the reason; recorded inBREAKING-CHANGES.md. TheSolveHardandSolveMediumHardanswers are the same size as before (149,153 and 37,073 nodes) and the corpus gate holds.Checks
Full suite in two chunks: 9,661 passed, 0 failed (Calculus 1,322, the rest 8,339).
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura