differentiate
Computes the derivative of a mathematical expression with respect to a variable. Supports polynomials, trig, exponential, and logarithmic functions.
Instructions
Computes the derivative of a mathematical expression with respect to a variable.
Supports polynomials, trigonometric functions, exponential functions, logarithms, and other functions supported by SymPy.
Args: expression: The mathematical expression to differentiate as a string. Examples: "x**2", "sin(x)", "exp(x)", "log(x)" variable: The variable with respect to which to differentiate. Default is "x". Optionally, other variables can be specified.
Returns: On success: {"result": } On error: {"error": }
Examples: >>> differentiate("x**2") {'result': '2x'} >>> differentiate("sin(x)") {'result': 'cos(x)'} >>> differentiate("xy", "y") {'result': 'x'} >>> differentiate("exp(x)") {'result': 'exp(x)'}
Notes: - Use mathematical notation with explicit operators (* for multiplication) - Powers can be represented with ** or ^ (e.g., x**2 or x^2) - For trigonometric functions, use sin(x), cos(x), etc. - Only support for one variable at a time (implicit differentiation not supported)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variable | No | x | |
| expression | Yes |