calculate_expression
Parse and compute mathematical expressions, including arithmetic, algebra, calculus, matrix operations, and equation solving, using symbolic computation.
Instructions
calculate mathematical expressions using the sympify
function from sympy
, parse and compute the input mathematical expression string, supports direct calls to SymPy functions (automatically recognizes x, y, z as symbolic variables)
Parameters:
expression (str): Mathematical expression, e.g., "223 - 344 * 6" or "sin(pi/2) + log(10)".Replace special symbols with approximate values, e.g., pi → 3.1415"
Example expressions:
"2 + 35" # Basic arithmetic → 17
"expand((x + 1)x - 15)" # Factorize → (x - 5)(x + 3)
"series(cos(x), x, 0, 4)" # Taylor series → 1 - x²/2 + x⁴/24 + O(x⁴)
"integrate(exp(-x2)*sin(x), (x, -oo, oo))" # Complex integral
"solve([x2 + y**2 - 1, x + y - 1], [x, y])" # Solve system of equations
"Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).eigenvals()" # Matrix eigenvalues
Returns:
str: Calculation result. If the expression cannot be parsed or computed, returns an error message (str).
Input Schema
Name | Required | Description | Default |
---|---|---|---|
expression | Yes |