Expand description
Symbolic algebra — a small computer-algebra system (CAS).
Expression trees over rationals/reals + variables, with simplify,
differentiate, numeric eval, and symbolic equation solving. This is the
ALGEBRA_MANIFOLD_PLAN.md Phase 3 module and is DELIBERATELY distinct from
solvers/symbolic_logic (which is SAT / defeasible LOGIC, not computer algebra).
The CAS is an authoring / tooling path and may allocate (Box, String); it must
NOT be used on an NQuin/SlgArena hot path. Results can be bridged back into the
graph via expr_citation_hash for provenance.
Enums§
- Expr
- A symbolic expression over real constants and named variables.
Functions§
- add
- c
- cos
- differentiate
- Symbolic derivative of
exprwith respect to variablewrt. The result is NOT auto-simplified — callsimplifyon it for a compact form. - div
- exp
- expand
- Distribute every product over sums and expand small positive integer powers, so the
result contains no
Mul/Pownode with an additive child. Semantically equal to the input (verify by evaluation). Powers above 8 are left unexpanded to bound blow-up. - expr_
citation_ hash - A stable provenance hash of an expression’s canonical form, for citing symbolic
results back into the graph (Phase 3.8 bridge). Two structurally-equal expressions
hash equally; this is
q_hashover the canonicalDisplaystring. - factor_
quadratic - Factor a real quadratic
a·x² + b·x + cintoa·(x − r₁)·(x − r₂)when it has real roots. ReturnsNonewhen the discriminant is negative (no real factorisation) ora = 0. Root constants are snapped to integers/halves when numerically close, so the common rational case factors cleanly. - from_
quins - Reconstruct an expression from a post-order
Vec<NQuin>produced byto_quins. - ln
- mul
- neg
- parse
- Parse a textual expression like
"x^3 - 2*x^2 + 5"or"sqrt(b^2 - 4*a*c)"into anExpr. Supports+ - * / ^, parentheses,sqrt(...), numbers and identifiers. - pow
- simplify
- Simplify an expression: constant folding, identity elimination (
x+0,x·1,x·0,x⁰,x¹,−(−x),x/1,x−x,x/x) and collection of an identicalx+x → 2·x. Applied to a fixpoint (bounded). - sin
- solve_
quadratic_ symbolic - Symbolic roots of
a·x² + b·x + c = 0with real coefficients, as exactExprs(-b ± √(b²−4ac)) / (2a). Returns the two root expressions (simplified). Fora = 0returns the single linear root-c/b. - sqrt
- sub
- tan
- to_
quins - Serialise an expression into a post-order
Vec<NQuin>(the root is the last element). - var