---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/tools/math/variables/calculateTool.md
description: >-
  Evaluates a mathjs-syntax expression and returns the numeric result alongside
  the KaTeX representation of the parsed expression.
---

# Variable: calculateTool

```ts
const calculateTool: Tool<SpooledArtifact>;
```

Defined in: [batteries/tools/math/index.ts:406](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/tools/math/index.ts#L406)

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.
