PHPackages                             coquibot/coqui-toolkit-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. coquibot/coqui-toolkit-calculator

ActiveLibrary

coquibot/coqui-toolkit-calculator
=================================

Math calculator toolkit for Coqui — evaluate arithmetic, scientific, and algebraic expressions with batch support

v0.1.1(1mo ago)00MITPHPPHP ^8.4CI passing

Since Apr 9Pushed 1mo agoCompare

[ Source](https://github.com/carmelosantana/coqui-toolkit-calculator)[ Packagist](https://packagist.org/packages/coquibot/coqui-toolkit-calculator)[ RSS](/packages/coquibot-coqui-toolkit-calculator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Coqui Calculator Toolkit
========================

[](#coqui-calculator-toolkit)

Math expression evaluator toolkit for [Coqui](https://github.com/AgentCoqui/coqui). Provides a token-efficient `calculate` tool that evaluates arithmetic, scientific, and algebraic expressions — powered by [nxp/math-executor](https://github.com/NeonXP/MathExecutor) with 60+ built-in functions.

Requirements
------------

[](#requirements)

- PHP 8.4+

Installation
------------

[](#installation)

```
composer require coquibot/coqui-toolkit-calculator
```

When installed alongside Coqui, the toolkit is **auto-discovered** via Composer's `extra.php-agents.toolkits` — no manual registration needed.

Tools Provided
--------------

[](#tools-provided)

### `calculate`

[](#calculate)

Evaluate one or more math expressions in a single call.

ParameterTypeRequiredDescription`expressions`stringYesSemicolon-delimited math expressions (e.g. `2+3; sin(pi/4); x=5; x^2`)`precision`stringNoDecimal precision. Default: 10. Use `bcmath:N` for arbitrary precision.**Features:**

- Batch evaluation — semicolon-delimited expressions evaluated in sequence
- Variable support — assign variables that carry forward within a call (`x=5; 2*x+3`)
- 60+ built-in functions — trig, logarithmic, rounding, statistics, base conversion
- Per-expression error handling — a bad expression doesn't kill the batch
- BCMath mode — arbitrary precision via `precision: "bcmath:20"`
- No credentials required — pure PHP computation

### Supported Functions

[](#supported-functions)

CategoryFunctionsArithmetic`+`, `-`, `*`, `/`, `%`, `^`Trigonometricsin, cos, tan, asin, acos, atan, atan2Hyperbolicsinh, cosh, tanhLogarithmiclog (natural), log10, log1p, exp, expm1Roundingceil, floor, round, absRoots/Powersqrt, pow, hypotStatisticsmin, max, avg, medianConversiondeg2rad, rad2deg, bindec, decbin, hexdec, dechex, octdec, decoctOtherfmod, intdiv, pi, if(cond, true, false)Constants`pi` (3.14159...), `e` (2.71828...)### Output Format

[](#output-format)

**Single expression** — returns the raw result value:

```
5

```

**Batch expressions** — returns a JSON array:

```
[{"expr":"2+3","result":5},{"expr":"sin(pi/4)","result":0.7071067812},{"expr":"x=10","result":10},{"expr":"x^2","result":100}]
```

**Errors** — per-expression error fields without stopping the batch:

```
[{"expr":"2+3","result":5},{"expr":"1/0","error":"Division by zero"},{"expr":"4*5","result":20}]
```

Standalone Usage
----------------

[](#standalone-usage)

```
