Safely evaluate mathematical expressions with support for basic operations and math functions.
Supported operations: +, -, *, /, **, ()
Supported functions: sin, cos, tan, log, sqrt, abs, pow
Note:
Use this tool to evaluate a single mathematical expression. To compute descriptive statistics over a list of numbers, use the statistics tool instead.
Examples:
- "2 + 3 * 4" → 14
- "sqrt(16)" → 4.0
- "sin(3.14159/2)" → 1.0
Parameters (1)
expressionstringrequired
Mathematical expression to evaluate. Supports +, -, *, /, **, and math functions (sin, cos, sqrt, log, etc.). Example: '2 * sin(pi/4) + sqrt(16)'
calc_statistics
Perform statistical calculations on a list of numbers.
Available operations: mean, median, mode, std_dev, variance
Note:
Use this tool to compute descriptive statistics over a list of numbers. To evaluate a single mathematical expression, use the calculate tool instead.
Examples:
statistics([1.0, 2.5, 3.0, 4.5, 5.0], "mean") # Returns 3.2
statistics([1.0, 2.5, 3.0, 4.5, 5.0], "std_dev") # Returns ~1.58
Parameters (2)
numbersarrayrequired
List of numbers to compute descriptive statistics on. Example: [1.0, 2.5, 3.0, 4.5, 5.0]
Calculate compound interest for investments.
Formula: A = P(1 + r/n)^(nt)
Where:
- P = principal amount
- r = annual interest rate (as decimal)
- n = number of times interest compounds per year
- t = time in years
Examples:
compound_interest(10000, 0.05, 5) # $10,000 at 5% for 5 years → $12,762.82
compound_interest(5000, 0.03, 10, 12) # $5,000 at 3% compounded monthly → $6,744.25
Parameters (4)
principalnumberrequired
Initial investment amount in dollars (must be > 0), e.g. 1000.0
ratenumberrequired
Annual interest rate as decimal 0.0-1.0 (e.g. 0.05 = 5%). If entering a percentage, divide by 100 first.
timenumberrequired
Investment time in years (must be > 0), e.g. 10.0
compounds_per_yearinteger
Compounding frequency per year (must be > 0): 12=monthly, 365=daily
calc_units
Convert between different units of measurement.
Supported unit types:
- length: mm, cm, m, km, in, ft, yd, mi
- weight: g, kg, oz, lb
- temperature: c, f, k (Celsius, Fahrenheit, Kelvin)
Examples:
convert_units(5, "km", "mi", "length") # 5 kilometers → 3.11 miles
convert_units(150, "lb", "kg", "weight") # 150 pounds → 68.04 kilograms
Parameters (4)
valuenumberrequired
Numeric value to convert, e.g., 100.0
from_unitstringrequired
Source unit abbreviation. Valid units depend on unit_type: length (mm, cm, m, km, in, ft, yd, mi), weight (g, kg, oz, lb), temperature (c, f, k)
to_unitstringrequired
Target unit abbreviation. Valid units depend on unit_type: length (mm, cm, m, km, in, ft, yd, mi), weight (g, kg, oz, lb), temperature (c, f, k)
unit_typestringrequired
Unit category: length, weight, or temperature
matrix_multiply
Multiply two matrices (A × B).
Note:
Requires NumPy. Raises ValueError if NumPy is unavailable.
Examples:
matrix_multiply([[1, 2], [3, 4]], [[5, 6], [7, 8]])
matrix_multiply([[1, 2, 3]], [[1], [2], [3]])
Parameters (2)
matrix_aarrayrequired
2D list of numbers representing the first matrix. Each inner list is a row. Example: [[1, 2], [3, 4]]
matrix_barrayrequired
2D list of numbers representing the second matrix. Each inner list is a row. Example: [[5, 6], [7, 8]]
matrix_transpose
Transpose a matrix (swap rows and columns).
Note:
Requires NumPy. Raises ValueError if NumPy is unavailable.
Examples:
matrix_transpose([[1, 2, 3], [4, 5, 6]])
matrix_transpose([[1], [2], [3]])
Parameters (1)
matrixarrayrequired
2D list of numbers representing the matrix. Each inner list is a row. Example: [[1, 2, 3], [4, 5, 6]]
matrix_determinant
Calculate the determinant of a square matrix.
Note:
Requires NumPy. Raises ValueError if NumPy is unavailable.
Examples:
matrix_determinant([[1, 2], [3, 4]])
matrix_determinant([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) # Identity matrix
Parameters (1)
matrixarrayrequired
2D list of numbers representing a square matrix. Each inner list is a row. Example: [[1, 2], [3, 4]]
matrix_inverse
Calculate the inverse of a square matrix.
Note:
Requires NumPy. Raises ValueError if NumPy is unavailable.
Examples:
matrix_inverse([[1, 2], [3, 4]])
matrix_inverse([[2, 0], [0, 2]]) # Diagonal matrix
Parameters (1)
matrixarrayrequired
2D list of numbers representing a square matrix. Each inner list is a row. Example: [[1, 2], [3, 4]]
matrix_eigenvalues
Calculate the eigenvalues of a square matrix.
Note:
Requires NumPy. Raises ValueError if NumPy is unavailable.
Examples:
matrix_eigenvalues([[4, 2], [1, 3]])
matrix_eigenvalues([[3, 0, 0], [0, 5, 0], [0, 0, 7]]) # Diagonal matrix
Parameters (1)
matrixarrayrequired
2D list of numbers representing a square matrix. Each inner list is a row. Example: [[4, 2], [1, 3]]
workspace_save
Save calculation to persistent workspace (survives restarts).
Examples:
save_calculation("portfolio_return", "10000 * 1.07^5", 14025.52)
save_calculation("circle_area", "pi * 5^2", 78.54)
Parameters (3)
namestringrequired
Variable name for the saved calculation. Used to retrieve it later. Example: 'circle_area'
expressionstringrequired
The mathematical expression that was evaluated. Example: 'pi * r**2'
resultnumberrequired
Numeric result of evaluating the expression, e.g., 78.54
workspace_load
Load previously saved calculation result from workspace.
Examples:
load_variable("portfolio_return") # Returns saved calculation
load_variable("circle_area") # Access across sessions
Parameters (1)
namestringrequired
Name of the variable to load from workspace, e.g., 'circle_area'
List of numeric values to bin, e.g., [1.0, 2.0, 2.5, 3.0]
binsinteger
Number of histogram bins, e.g., 20
titlestring
Chart title string, e.g., 'Data Distribution'
plot_line_chart
Create a line chart from data points (requires matplotlib).
Note:
Use for general XY data. For time-series price data with optional moving average, use plot_financial_line instead.
Examples:
plot_line_chart([1, 2, 3, 4], [1, 4, 9, 16], title="Squares")
plot_line_chart([0, 1, 2], [0, 1, 4], color='red', x_label='Time', y_label='Distance')
Parameters (7)
x_dataarrayrequired
X-axis data points, e.g., [1, 2, 3, 4]
y_dataarrayrequired
Y-axis data points, e.g., [1, 4, 9, 16]
titlestring
Chart title string, e.g., 'Squares'
x_labelstring
X-axis label, e.g., 'Time'
y_labelstring
Y-axis label, e.g., 'Distance'
colorany
Line color (name or hex code, e.g., 'blue', '#2E86AB')
show_gridboolean
Whether to display grid lines
plot_scatter
Create a scatter plot from data points (requires matplotlib).
Examples:
plot_scatter([1, 2, 3, 4], [1, 4, 9, 16], title="Correlation Study")
plot_scatter([1, 2, 3], [2, 4, 5], color='purple', point_size=100)
Parameters (7)
x_dataarrayrequired
X-axis data points, e.g., [1, 2, 3, 4]
y_dataarrayrequired
Y-axis data points, e.g., [1, 4, 9, 16]
titlestring
Chart title string, e.g., 'Correlation Study'
x_labelstring
X-axis label, e.g., 'Variable X'
y_labelstring
Y-axis label, e.g., 'Variable Y'
colorany
Point color (name or hex code, e.g., 'blue', '#2E86AB')
List of data groups to compare, e.g., [[1, 2, 3], [4, 5, 6]]
group_labelsany
Labels for each group, e.g., ['Group A', 'Group B']
titlestring
Chart title string, e.g., 'Distribution Comparison'
y_labelstring
Y-axis label, e.g., 'Values'
colorany
Box color (name or hex code, e.g., 'blue', '#2E86AB')
plot_financial_line
Generate and plot synthetic financial price data (requires matplotlib).
Creates realistic price movement patterns for educational purposes.
Does not use real market data.
Note:
Use for time-series price data with optional moving average overlay. For general XY data, use plot_line_chart instead.
Examples:
plot_financial_line(days=60, trend='bullish')
plot_financial_line(days=90, trend='volatile', start_price=150.0, color='orange')
Parameters (4)
daysinteger
Number of days to generate, e.g., 30
trendstring
Market trend direction
start_pricenumber
Starting price value, e.g., 100.0
colorany
Line color (name or hex code, e.g., 'blue', '#2E86AB')
The calc_expression tool uses restricted eval() with a whitelist of allowed characters and functions, restricted global scope (only math module and abs), and no access to dangerous built-ins or imports. All tool inputs are validated with Pydantic models. File operations are restricted to the designated workspace directory. Complete type hints and validation are enforced for all operations.