Overview
Calculator tool for performing mathematical calculations including basic arithmetic, scientific functions, and expression evaluation. The user asks a math question; the agent evaluates the expression with the calculator and returns the result.Installation
Quick Start
Usage with Agent
Available Methods
calculate(expression)
Evaluate a mathematical expression.Scientific Functions
Function-Based Usage
CLI Usage
Supported Operations
| Operation | Symbol | Example |
|---|---|---|
| Addition | + | 5 + 3 |
| Subtraction | - | 10 - 4 |
| Multiplication | * | 6 * 7 |
| Division | / | 20 / 4 |
| Power | ** | 2 ** 8 |
| Modulo | % | 17 % 5 |
| Parentheses | () | (2 + 3) * 4 |
Supported Functions
sin,cos,tan- Trigonometricasin,acos,atan- Inverse trigonometricsqrt- Square rootlog,log10- Logarithmsexp- Exponentialabs- Absolute valueround,floor,ceil- Rounding
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
Division by zero | Dividing by 0 | Check divisor |
Invalid syntax | Malformed expression | Check expression format |
Unknown function | Unsupported function | Use supported functions |
How It Works
Best Practices
Prefer the calculator over the LLM for math
Prefer the calculator over the LLM for math
LLMs approximate arithmetic. Route numeric work through the calculator tool for exact answers.
Guard against division by zero
Guard against division by zero
Wrap
calculate in error handling so a bad expression returns a message instead of crashing the agent.Use parentheses for clarity
Use parentheses for clarity
Explicit parentheses make the agent’s intended order of operations unambiguous.
Related Tools
Python
Execute Python code
Pandas
Data analysis

