/** * Pre-constructed tools for safe arithmetic, expression evaluation, and numeric operations. * * @module @nhtio/adk/batteries/tools/math * * @remarks * Pre-constructed bundled tools for the `math` category. Import individually, the whole * category, or import every tool via `@nhtio/adk/batteries`. */ import { Tool } from "../../../common"; /** * Evaluates a mathjs-syntax expression and returns the numeric result alongside the KaTeX * representation of the parsed expression. * * @remarks * Supports arithmetic, trigonometric, logarithmic, exponential, factorial, matrix, and unit * operations via `mathjs`. The mathjs instance is hardened: dangerous functions (`import`, * `createUnit`, `simplify`, `derivative`, `compile`, `chain`, `reviver`, `replacer`) are * disabled to prevent interpreter-surface exposure. * * Expressions over 1000 characters are rejected with an error string (not thrown). Parse and * evaluation errors are also returned as error strings — the tool surfaces math errors as * content rather than exceptions, so the model can react to them in-line. */ export declare const calculateTool: Tool; /** * Translates a LaTeX/KaTeX expression using evaluatex and returns the numeric result. * * @remarks * Uses the evaluatex library to parse and evaluate LaTeX expressions. Handles common constructs * (`\frac{a}{b}`, `\sqrt{...}`, `\cdot`, `\times`, Greek macros like `\pi`, inverse trig, * `\left`/`\right` delimiters, `\text{...}`, subscripts, etc.) with a proper parser rather than * brittle regex. * * Also evaluates three calculus constructs **numerically** (mathjs has no symbolic integration, and * its symbolic `derivative` is blocklisted here for safety): * - Definite integrals — `\int_{a}^{b} f \,dx` via composite Simpson quadrature. * - Derivatives at a point — `\frac{d}{dx} f \big|_{x=a}` via central finite difference. * - Limits — `\lim_{x \to a} f` (including `a = \pm\infty`) via a two-sided numeric approach. * * Numeric results are rounded with `math.format(..., { precision: 12 })` and labelled * `Result (numeric):` to flag that they are approximations. Constructs that cannot be evaluated * numerically (indefinite integrals, derivatives without a point, infinite integration bounds, * singular integrands, divergent limits) return a specific, guiding error string. * * Parse and evaluation errors are returned as error strings rather than thrown. */ export declare const evaluateKatexTool: Tool;