Repository navigation
Remove nerdamer: SymPy is the only symbolic engine - #130
Merged
Merged
Conversation
expand and factor (whole numbers into primes), solve_system (linsolve for linear systems, a Groebner shape basis for polynomial systems, whole curves for dependent ones), roots with parameters, and indefinite integrals of abs and sign written with sign() instead of Piecewise. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
utils/polynomials.py reads a polynomial's coefficients from math.js's parse tree with exact fractions; utils/numeric_equations.py finds the real roots of an equation from the inequality sign chart when SymPy has no closed form. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
derive, expand and factor now ask the server's SymPy like the other tools, and systems of equations go to its solve_system (substitution for a transcendental pair with y = f(x), else the Newton solver). Without SymPy the symbolic tools say it is needed, while definite integrals, limits, solve and systems answer numerically and say so. The asymptote analysis reads polynomial coefficients from math.js's parse tree and scans for other zeros, so drawing needs no CAS. math.js now reads ln and sgn, so every numeric check reads them. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
The library, its limit() time guard and their script tags are gone; SymPy on the server is the only symbolic engine. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
Roadmap item 10 lists the change and its known gaps. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
Sign changes are narrowed by Illinois false position (about 10 evaluations instead of 40), denominator zeros get the quick pole verdict tan() poles already had, and the math.js probe runs in JavaScript so values past 2^53 no longer go through Brython's slow big-int exception. Unbounded 1/sin(x) drops from 2 s to about 0.5 s; 1/(e^x-2) from 0.55 s to 0.14 s. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
- solve: accept solveset's {root} \ {pole} answer and fall back to
sp.solve, checked at sample parameter values, for formulas solved for
a variable (R = V/I for I, T = 2*pi*sqrt(L/g) for g, a^x = b)
- arcsin, arccos, arctan, arcsec, arccsc and arccot are aliases of asin
and the rest, read by every symbolic tool and the evaluator
- the numeric root finder and inequality chart use the [-2*pi, 2*pi]
window only when the variable occurs only inside trig calls, or the
equation keeps changing sign far from 0 (with a note); x + sin(x) = 10
is solved on the whole grid
- the asymptote zero scan keeps the zeros nearest 0 and rescans the
middle finely when zeros are closer than its samples (1/sin(10x))
- systems read input as solve does (|x|, x(x+1)), refuse an equation
holding none of the unknowns instead of calling it a contradiction,
and solve linear systems by elimination without SymPy
- numeric_integrate names other names in the integrand
- the expression table golden records the new aliases; its math.js
recorder stands in for window.Function
Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
- solve: unwrap solveset's ConditionSet on the parameters (|x| = a gives a, -a) and keep a formula root that holds at any sample parameter values that make it real (A = P*(1-r)^t for t, sqrt(x) = a-5) - systems refuse glued products with an unknown (y = mx + b, y = ax^2) with the form to write, as solve does - the elimination for linear systems runs only without SymPy and checks linearity at spread-out points, so max(x, 1) is not taken for a line - the quick pole verdict avoids generators and casts (tan(10x) analysis 1.7 s -> 1.0 s) - the Roadmap lists the minor findings as follow-ups Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
xA and xB, vx and vy, xi and eta are names in a system without x, y or z alone; y = mx + b beside y = -x + 3 is still refused. A ConditionSet on the parameters is unwrapped only when its condition can hold. Claude-Session: https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S
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.
Requested by V · project thread
Before:
derive,expand,factorand systems of equations ran on nerdamer in the browser (unmaintained, with a time guard against its runawaylimit()), and the other CAS tools fell back to it when the server had no SymPy. Drawing a function asked nerdamer for denominator roots.After: SymPy on the server answers every symbolic tool, and every result is still checked numerically in the browser with math.js. nerdamer and
nerdamer_guard.jsare deleted. Without SymPy, the symbolic tools say it is needed, while definite integrals, limits,solve, systems (linear ones by elimination) andnumeric_integratestill answer numerically and say so. Drawing needs no CAS.What users and the model see change:
factor(360)is2^3*3^2*5;expand/factor/derivegive SymPy's forms (x^2+2*x+1).linsolve, with "No solution" and "Infinitely many ... for any y"), polynomial systems via a Groebner shape basis (every solution, a count of complex ones; a quintic system in 0.3 s), dependent curves, parameters kept (x + y = a).y = 2^x, y = x^2lists all three real solutions by substitution. Systems read|x|andx(x+1)assolvedoes; glued products beside their unknown (y = mx + b) and equations holding no unknown (b = 2) are refused with the form to write.solvewith no closed form (cos(x) = x) finds the real roots numerically from the inequality sign chart and says so: on [-2π, 2π] only when x occurs only inside trig calls or the equation keeps crossing (x*sin(x) = 1, with a note);x + sin(x) = 10andsin(x) = x/10on the whole line.R = V/Ifor I,T = 2*pi*sqrt(L/g)for g,a^x = b,|x| = a,N = N0*e^(-k*t)for t.arcsin,arccos,arctan(andarcsec,arccsc,arccot) are aliases everywhere, includingevaluate.x^2*sign(x)/2instead of SymPy's Piecewise (which was refused).lnandsgn, so every numeric check reads them.How:
static/sympy_cas.py:expand,factor,solve_system, roots with parameters (solveset, elsesp.solvechecked at sample parameter values), Piecewise-free antiderivatives.static/client/utils/polynomials.py: coefficients from math.js's parse tree in exact fractions;utils/numeric_equations.py: roots from the sign chart;utils/linear_systems.py: elimination without SymPy.math_utils.py: tools ask SymPy only; zeros of non-polynomial denominators andabsarguments come from a scan of [-1000, 1000] (Illinois false position, zeros nearest 0 kept, a finer rescan where zeros are dense), probed through one JavaScript function.WithoutSympystays, to pin the no-SymPy path (design review M2).Reviewed in three independent rounds (reports in the project folder); the minor findings are listed as follow-ups under Roadmap A1 CAS reliability 10.
Tests: server 4250 passed; client 4059/4059 locally; CI green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QyBvusqEMjyZ7mMd45ji2S