Skip to main content

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

No API key required!

Quick Start

1

Simple Usage

2

With Configuration

Use the same tool with an agent — see Usage with Agent below, or pass env vars and options from the sections above.

Usage with Agent

Available Methods

calculate(expression)

Evaluate a mathematical expression.

Scientific Functions

Function-Based Usage

CLI Usage

Supported Operations

Supported Functions

  • sin, cos, tan - Trigonometric
  • asin, acos, atan - Inverse trigonometric
  • sqrt - Square root
  • log, log10 - Logarithms
  • exp - Exponential
  • abs - Absolute value
  • round, floor, ceil - Rounding

Error Handling

Common Errors

How It Works


Best Practices

LLMs approximate arithmetic. Route numeric work through the calculator tool for exact answers.
Wrap calculate in error handling so a bad expression returns a message instead of crashing the agent.
Explicit parentheses make the agent’s intended order of operations unambiguous.

Python

Execute Python code

Pandas

Data analysis