-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
{
"name": "calculator",
"description": "Call this function whenever complex mathematical expressions are involved. Evaluates a single symbolic expression using SymPy. Supports constants (pi, E, I), algebra (+, -, *, /, **, sqrt, factor, simplify), trigonometry (sin, cos, tan, asin, acos, atan), logarithms (log with base), combinatorics (factorial, comb, perm), and calculus (diff, integrate, limit). Expressions are symbolic; no substitution.",
"parameters": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "A single symbolic expression as a string, e.g. 'sin(pi/4) + sqrt(2)'"
}
},
"required": ["expression"]
}
}
def calculator(expression: str) -> str:
"""
Evaluate a single symbolic expression using SymPy and return numeric result
rounded to 5 decimal places.
"""
try:
# Parse string into SymPy expression
expr = sympify(expression)
# Evaluate numerically and round to 5 decimal places
return str(round(float(expr.evalf()), 5))
except Exception as e:
return f"Error: {e}"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request