You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds an initial, modular differential-equation solving slice for the compute engine:
registers symbolic DSolve in the calculus library
implements symbolic first-order linear scalar ODE solving in src/compute-engine/symbolic/differential-equations.ts
registers numeric NDSolve in the calculus library
implements fixed-step scalar RK4 support in src/compute-engine/numerics/differential-equations.ts
adds focused tests for symbolic solutions, unsupported inert cases, RK4 sample accuracy, and a Gaussian IVP with a non-elementary antiderivative checked against Erf
Scope / Limitations
This is intentionally narrow so the API and result shape can get feedback before broader ODE support is added.
Current symbolic support handles first-order linear equations of the form y'(x) + p(x)y(x) = q(x) and leaves unsupported/nonlinear/higher-order equations inert.
Current numeric support handles explicit scalar first-order IVPs with fixed-step RK4 and returns sample data as a List of [x, y] pairs. It does not yet implement adaptive RK45, systems, interpolation objects, stiff solvers, implicit equations, or higher-order reductions.
This looks good overall and fits well with the conventions of the Compute Engine.
A few small things:
For the integration constant, use a generated constant name (avoiding freeVariables in the expression) instead of hardcoding C, or alternatively start with C if it is not an already defined identifier in scope, and fallback to a constructed constant name if it is.
For NDSolve, use canonicalLimits() to parse the operand, to handle cases like a simple Tuple/Tripe (forms which are also supported by the Integrate/Sum operators).
I'd suggest that DSolve should return a List, so that it can represent solution families in the future without changing the API shape.
You have a few functions (isDependentFunction(), isDerivativeOfDependent() and the symbolArg closure) that should be promoted to shared helpers to avoid duplication.
In NDSolve you can use compiled.success for a quick bypass.
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
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.
Summary
Adds an initial, modular differential-equation solving slice for the compute engine:
DSolvein the calculus librarysrc/compute-engine/symbolic/differential-equations.tsNDSolvein the calculus librarysrc/compute-engine/numerics/differential-equations.tsErfScope / Limitations
This is intentionally narrow so the API and result shape can get feedback before broader ODE support is added.
Current symbolic support handles first-order linear equations of the form
y'(x) + p(x)y(x) = q(x)and leaves unsupported/nonlinear/higher-order equations inert.Current numeric support handles explicit scalar first-order IVPs with fixed-step RK4 and returns sample data as a
Listof[x, y]pairs. It does not yet implement adaptive RK45, systems, interpolation objects, stiff solvers, implicit equations, or higher-order reductions.Validation
node_modules/.bin/jest.cmd --config ./config/jest.config.cjs test/compute-engine/differential-equations.test.ts --runInBand --reporters defaultnode_modules/.bin/jest.cmd --config ./config/jest.config.cjs test/compute-engine/calculus.test.ts --runInBand --reporters default --testNamePattern DERIVATIONnode_modules/.bin/madge.cmd --circular --extensions ts src/compute-enginenode_modules/.bin/tsc.cmd --target es2022 --module es2022 --moduleResolution bundler --types node --skipLibCheck -d --allowImportingTsExtensions true --emitDeclarationOnly --ignoreConfig --outDir .typecheck ./src/compute-engine.ts