use-calculus
use-calculus provides a deliberately small numerical-calculus surface. The crate prefers explicit assumptions over magic defaults: finite-difference steps are caller-chosen, integration sample counts are explicit, and two-sided limit estimates fail when the left and right samples do not agree within a caller-provided tolerance.
What this crate provides
| Area | Root exports | Best fit |
|---|---|---|
| Differentiation | Differentiator, central_difference, second_central_difference |
Small slope and curvature estimates on f64 functions |
| Integration | IntegrationInterval, Integrator, trapezoidal_integral, simpson_integral |
Signed area approximations with explicit sample density |
| Limits | LimitApproximator, symmetric_limit |
Two-sided limits where a single symmetric sample scale is a reasonable model |
| If you need to... | Start here |
|---|---|
| Estimate a derivative at one point | Differentiator::derivative_at(...) |
| Approximate a definite integral | Integrator::trapezoidal(...) or Integrator::simpson(...) |
| Model a signed interval directly | IntegrationInterval::try_new(...) |
| Reject discontinuities instead of hiding them | symmetric_limit(...) or LimitApproximator |
When to use it directly
Choose use-calculus directly when numerical-calculus helpers are the only math surface you need, or when you want the approximation policy to stay visible instead of being hidden behind a broader abstraction.
| Scenario | Use use-calculus directly? |
Why |
|---|---|---|
| You need a few direct derivative or integral estimates | Yes | The crate stays small and explicit |
| You want validation at the boundary of your app | Yes | Invalid steps, bounds, and evaluations become errors |
| You need symbolic manipulation or automatic differentiation | No | This crate intentionally stays numerical and lightweight |
| You also need several other math surfaces | Usually no | use-math may become the better integration point |
Installation
[]
= "0.0.1"
Quick examples
Differentiate and integrate small f64 functions
use ;
let differentiator = try_new?;
let interval = try_new?;
let integrator = try_new?;
let slope = differentiator.derivative_at?;
let area = integrator.simpson?;
assert!;
assert!;
# Ok::
Explicitly reject mismatched one-sided limits
use ;
let limit = try_new?;
let sinc_limit = limit.at?;
assert!;
assert!;
# Ok::
Validation model
Use try_new when sample sizes, step sizes, tolerances, and interval bounds may come from user input, files, or network payloads. Use infallible constructors like Differentiator::new(...), IntegrationInterval::new(...), Integrator::new(...), and LimitApproximator::new(...) when values are already trusted and you want direct assembly.
[!IMPORTANT] This crate does not hide approximation policy behind a global epsilon or default grid density. Callers choose the differentiation step, integration density, and limit tolerance directly.
Scope
- Small numerical APIs are preferred over symbolic or trait-heavy abstractions.
- The initial concrete surface is
f64-based and focused on explicit approximation helpers. - Adaptive quadrature, automatic differentiation, and symbolic manipulation are intentionally out of scope for this first slice.
- Broader real-number utilities and statistical analysis belong in adjacent focused crates.
Status
use-calculus is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while the broader calculus roadmap is still being designed.