ORIXSymbolic — validation report
State on 2026-11-20. Toolchain: Swift 6.4.2 (language mode 6, strict concurrency), macOS 27. Reference: sympy 1.14.0 and
mpmath 1.3.0 (Reference/generate_reference.py → Reference/reference.json, copied into the test bundle).
How results are validated
- Inside the engine, on every call (recorded as
VerificationChecks in the result):- antiderivatives are differentiated and compared with the integrand at up to 10 sample points (and exactly when the
difference simplifies to 0); a candidate that fails is discarded and the result is
.unsupported; - exact definite integrals are cross-checked against adaptive quadrature; on disagreement the exact value is discarded and the numerical one is returned;
- derivatives are compared with a numerical (Ridders) derivative; simplify/expand results with the input value at sample points;
- every root of an equation is substituted into the original equation (extraneous roots are rejected and listed);
- exact limits are compared with a numerical approach to the point; exact linear solutions are substituted exactly;
- factorizations are multiplied back and compared exactly; closed-form sums are compared with direct summation;
- ODE solutions are re-computed with tighter tolerances (or twice the steps) to estimate the error.
- antiderivatives are differentiated and compared with the integrand at up to 10 sample points (and exactly when the
difference simplifies to 0); a candidate that fails is discarded and the result is
- In the test suite, against an independent reference. Symbolic forms differ between systems, so the comparison is
semantic: both results are evaluated at pseudo-random points and must agree to 1e-8 … 1e-10. For integrals the reference is
mpmath quadrature of the integrand (it does not depend on sympy finding an antiderivative). A set of exact structural
expectations covers the canonical simple cases (
d/dx x²prints2x).
Test inventory
swift test: 58 tests in 10 suites, all passing; swift build / swift build -c release produce no warning from this
package (the only warning printed comes from the manifest of the BigInt dependency, as in ORIXExpression).
| Area | Cases | Reference |
|---|---|---|
| Derivatives (all elementary, trig, inverse trig, hyperbolic, inverse hyperbolic, logs in any base, u^v, partials, orders 2–5) | 83 | sympy diff, 6 points each |
| Derivatives of random expression trees | 150 generated | Ridders numerical derivative |
| Indefinite integrals (each also re-differentiated in the test) | 88 | mpmath quadrature, 5 intervals each |
| Definite integrals (exact, improper, numerical fallbacks) | 20 + 20 structural | mpmath quadrature |
| Simplification: idempotence and value preservation | 136 corpus + 600 random trees | sympy evaluation / direct evaluation |
| Limits (two-sided, one-sided, at ±∞, infinite, non-existent) | 37 + 16 structural | sympy limit |
| Taylor coefficients | 20 series (orders 3–7) | sympy |
| Polynomial equations (real roots, complex count, multiplicities) | 18 | sympy nroots |
| Other equations (isolation, substitution, radical, trig, parameters, numerical) | about 40 | hand-checked values, residuals |
| Polynomial division, GCD | 8 pairs + 60 random identities (a = q·b + r, product rule, Horner, composition) | sympy div, gcd |
Factorisation (factor lists, multiplicities, factor(expand(p)) round trip) |
18 + 12 random | sympy factor_list |
| Finite sums in closed form | 8 | sympy summation |
| Linear systems (unique, inconsistent, underdetermined, 8×8 Hilbert) | 9 | exact substitution |
| Nonlinear systems | 5 | residuals, known solution sets |
| Optimisation (1-D exact and numerical, multivariate) | 12 | closed forms |
| ODEs (decay, tolerance sweep, harmonic oscillator energy, RK4 order, logistic, coupled, failures) | 7 tests | closed forms with error bounds |
| Unsupported / refusal paths | about 45 | — |
| Bounds and performance | 3 tests | — |
Measured: a 461-node expression is simplified in about 5 ms in a debug build (the test asserts < 50 ms for ≥ 200 nodes).
What is supported
- Simplify: canonical sums and products (flattening, ordering, like terms, like powers), exact rational folding, simplified
radicals (√8 → 2√2), cancellation of common polynomial factors in quotients, numeric content of sums,
sin² + cos² = 1,cosh² − sinh² = 1,e^(ln x),ln(e^x), exact trigonometric values at multiples of π/6 and π/4, parity of odd/even functions,i² = −1,√(x²) = |x|. WithassumePositive:√(x²) = x,ln(ab),ln(x^a),|x| = x.expand(products, integer powers up to 64, bounded size).factorover ℚ for one-variable polynomials: content, square-free decomposition, rational roots, factors of degree 2–4 by Kronecker's method. - Polynomials (
Polynomial, exact rational coefficients): arithmetic, division with remainder, primitive GCD, derivative, antiderivative, Horner evaluation, composition. Roots: exact for linear and quadratic factors (real surds, complex conjugate pairs withi) and for biquadratic quartics; multiplicities from the square-free decomposition. - Differentiation: complete for the function set listed above, plus
abs,sign,floor/ceil/round/trunc/frac(with a stated assumption),erf,erfc,atan2; any order up to 20, mixed partials, gradient. - Integration (rule engine): linearity, power rule, table for exp / trig / hyperbolic / inverse functions of a linear
argument, powers of trig and hyperbolic functions (power reduction, reduction formulas),
ln^k, products of sines and cosines,e^(ax)·sin(bx)/cos(bx), polynomial × exp / sin / cos / sinh / cosh (tabular parts), by parts withlnand inverse functions, rational functions by partial fractions (linear and irreducible quadratic factors, repeated),1/√q,√qand1/qfor a quadratic q, u-substitution, linear substitution with back-substitution, expansion fallback. Definite integrals as described in API.md. - Solve: polynomial equations, linear/quadratic with symbolic coefficients, isolation by inverse operations, one radical,
substitutions (
e^(kx), a function of x,√x), numerical fallback on an interval. Linear systems exactly (up to 60 × 60), nonlinear systems numerically (1–6 unknowns). - Limits: substitution, cancellation, L'Hôpital (0/0, ∞/∞, 0·∞), logarithmic transformation for u^v, limits at ±∞ (degree comparison, substitution x = 1/t), squeeze for bounded × vanishing, one-sided limits, locally constant functions (floor, sign).
- Series: Taylor polynomials up to order 30 with exact coefficients; sums of polynomials (any degree up to 24), arithmetic and geometric progressions, convergent geometric series, exact evaluation for numeric bounds.
- Optimisation: 1-D on a closed interval; multivariate local minimisation (Nelder–Mead + BFGS).
- ODEs: explicit first-order systems (RK4, Dormand–Prince 5(4)), second order by reduction.
What is explicitly unsupported (returned as .unsupported, never guessed)
- Trigonometric input when the angle mode is DEG or GRAD (design choice: symbolic calculus is in radians; the π/180 factor is not applied silently).
- Integrals outside the rules above: non-elementary ones (
e^(−x²),sin(x)/x,x^x,1/ln x,√(1 + x⁴)), rational functions whose denominator has an irreducible factor of degree ≥ 3 over ℚ (1/(x⁴+1),1/(x³−2)), trigonometric substitution in general, Weierstrass substitution, special functions as results (erf,Si,Eiare not produced). A definite integral then gets a numerical value labelled.numerical. - Definite integrals with a singularity strictly inside the interval, or an integrand that is not real on part of it.
- Closed forms for irreducible cubics and quartics (no Cardano / Ferrari): their roots are numerical (Durand–Kerner with
Newton polishing and a residual check) and labelled
.numerical. - Factorisation of multivariate or non-polynomial expressions; factors beyond the Kronecker bounds are left as is and flagged
isProvenIrreducible == false. - Inequalities; equations with parameters that are not linear/quadratic or isolable; linear systems with symbolic or floating-point coefficients; complex solutions of non-polynomial equations.
- Derivatives of
gamma, factorial,min/max,if/piecewise. - Infinite series other than geometric ones; products; closed-form ODE solutions (the optional symbolic ODE classes were not implemented); stiff ODE solvers (stiffness is detected as a failure, not solved).
Known limitations (honest list)
- Trigonometric equations return the principal solutions only; the general solution is given as text in
note. - Numerical root search (
solvefallback) covers the given interval only (default [−10, 10]) and can miss roots of even multiplicity or roots closer together than the sampling step (interval / 4000). - Limits: forms needing algebraic conjugation (
√(x²+x) − xat ∞) are not solved exactly; they come back.numericalwith an extrapolation error estimate. Oscillating limits may come back.failedConvergence. The sign of an infinite limit and the "defined on this side" test use sampling near the point. - Taylor series at a removable singularity (
sin(x)/xat 0): each coefficient needs an exact limit of a derivative, which the limit engine often cannot produce; order 4 ofsin(x)/xreturns.unsupported(observed), lower orders were not tested. No Laurent or Puiseux series. - Singularity detection for definite integrals is by sampling (1500 points, plus a pole search) on the interval clipped to [−60, 60]; an extremely narrow pole could be missed. The quadrature cross-check is the second line of defence.
- Verification by sampling is strong evidence, not a proof; the tolerance is 1e-7 relative on up to 10 points.
- Simplification is canonical, not maximal: no trigonometric rewriting beyond the Pythagorean identities, no logarithm
combination, no nested-radical denesting, sums of fractions are not put over a common denominator automatically.
Exact fractions print as fractions (
0.1 + 0.2→3/10). - Symbolic parameters are assumed generic (e.g.
a ≠ 0ina·x + b = 0); the assumptions are listed inexplanation.assumptions. Definite integrals with parameters are not checked for continuity (a warning is attached). - Optimisation classifies with f″ and falls back to the sign change of f′; a critical point where f′ touches zero without
changing sign is reported as
inflection. Multivariate minimisation finds one local minimum from the starting point. - Size limits: 20 000 input nodes, nesting depth 400, expansion 4000 term products, polynomial degree 400, repeated
differentiation stops above 2500 nodes, at most 200 000 ODE steps. Exceeding a limit gives
.unsupported/.failedConvergence. - Performance figures were measured in debug builds on one machine (Apple Silicon); no device measurements were made.
Not validated
- Nothing was run on iOS / iPadOS hardware or simulators: the package was built and tested with
swift build/swift teston macOS only. - LaTeX output of results (
text(style: .latex)) was not checked beyond whatPrinterguarantees. - Behaviour with user-defined functions or native functions inside expressions (they are treated as unknown functions:
differentiation and integration return
.unsupported).