Module eval_numeric

Module eval_numeric 

Source
Expand description

Low-level numerical evaluation trait system

This module implements the two-level evaluation architecture following SymPy’s proven design:

  1. Low-level EvalNumeric trait: Type-specific numerical evaluation without substitution
  2. High-level evaluate() method: User-facing API with substitution, simplification, and control

§Architecture

The two-level design separates concerns:

  • EvalNumeric::eval_numeric(): Internal trait for numerical conversion (like SymPy’s _eval_evalf())
  • Expression::evaluate_with_context(): Public API with substitution and context control (like SymPy’s evalf())

This separation enables:

  • Clear semantics for each expression type
  • Explicit control over evaluation behavior
  • Extensibility for custom types

§Mathematical Background

Numerical evaluation converts symbolic expressions to numerical form while preserving mathematical correctness. For example:

  • sin(π/2)1.0 (exact symbolic evaluation)
  • sqrt(2)1.4142135623730951 (numerical approximation with precision control)
  • x^2 (with x=3) → 9 (after substitution and evaluation)

Structs§

EvalContext
Evaluation context

Traits§

EvalNumeric