Use this file to discover all available pages before exploring further.
MathCore provides two complementary integration modes: symbolic integration, which returns an exact antiderivative as an Expr; and numerical integration, which evaluates a definite integral over a closed interval using Simpson’s rule. Together they cover the most common integration needs — from finding antiderivatives of polynomials and trigonometric functions to approximating areas under arbitrary curves.
Returns Ok(Expr) containing the symbolic antiderivative (without a constant of integration), or Err(MathError) if the expression cannot be parsed.
MathCore does not append a constant of integration (+ C) to symbolic results. If you need it, add Expr::Symbol("C".to_string()) to the result manually.
For expressions that have no closed-form antiderivative, or whenever you need a numeric result over a specific interval, use the definite integration function. Internally it calls Calculus::numerical_integrate with 1 000 steps.
Number of sub-intervals. More steps → greater accuracy, slower.
The integrator uses composite Simpson’s 1/3 rule (evaluating the function at the left endpoint, midpoint, and right endpoint of each sub-interval, weighted 1 : 4 : 1) for O(h⁴) accuracy per step.
use mathcore::MathCore;use mathcore::calculus::Calculus;let expr = MathCore::parse("exp(-x^2)").unwrap(); // Gaussian — no closed form// High accuracy with 10 000 stepslet result = Calculus::numerical_integrate(&expr, "x", 0.0, 1.0, 10_000).unwrap();println!("∫₀¹ exp(-x²) dx ≈ {:.8}", result);
The default of 1 000 steps (used by MathCore::numerical_integrate) gives excellent accuracy for smooth functions. Increase steps when integrating highly oscillatory integrands.
When MathCore cannot find a closed-form antiderivative — for example, a product of two functions that both depend on the integration variable — it returns a symbolic Integral node rather than an error:
use mathcore::MathCore;// MathCore cannot integrate x * sin(x) symbolically (no IBP support yet)let result = MathCore::integrate("x * sin(x)", "x").unwrap();println!("{}", result); // ∫(x * sin(x)) dx — unevaluated Integral node
An Integral node in the result means the integral is unevaluated. You can still display it as a symbolic placeholder, but you cannot numerically evaluate the Integral node itself — use MathCore::numerical_integrate instead to obtain a numeric result for such expressions.