calculate_expression
Compute and simplify mathematical expressions, including algebra, calculus, and matrix operations, using symbolic computation and SymPy functions. Supports solving equations, derivatives, integrals, limits, and more.
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 + 3*5" # Basic arithmetic → 17
"expand((x + 1)2)" # Expand → x² + 2x + 1
"diff(sin(x), x)" # Derivative → cos(x)
"integrate(exp(x), (x, 0, 1))" # Definite integral → E - 1
"solve(x2 - 4, x)" # Solve equation → [-2, 2]
"limit(tan(x)/x, x, 0)" # Limit → 1
"Sum(k, (k, 1, 10)).doit()" # Summation → 55
"Matrix([[1, 2], [3, 4]]).inv()" # Matrix inverse → [[-2, 1], [3/2, -1/2]]
"simplify((x2 - 1)/(x + 1))" # Simplify → x - 1
"factor(x2 - 2*x - 15)" # Factorize → (x - 5)(x + 3)
"series(cos(x), x, 0, 4)" # Taylor series → 1 - x²/2 + x⁴/24 + O(x⁴)
"integrate(exp(-x*2)*sin(x), (x, -oo, oo))" # Complex integral
"solve([x**2 + 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 |