finite_differences
Approximate first and second derivatives of f(x) at a point using forward, backward, and central finite differences, then compare them with exact SymPy derivatives and errors.
Instructions
Approximate the first and second derivatives of f(x) at x with finite differences.
Computes forward, backward and central differences for the first derivative, plus the central second derivative, and compares each against the exact derivative from SymPy.
Args: func_str: Math expression in x. x_val: Point where the derivative is evaluated. h: Step size (small, positive). precision: Rounding digits. plot: When True, also return a PNG of f(x) and its exact tangent.
Returns:
Dict with the exact and numerical derivatives and their errors. With
plot=True a list [dict, Image] is returned instead.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"func_str": "<func_str>",
"x_val": "<x_val>"
},
"name": "finite_differences"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| h | No | ||
| plot | No | ||
| x_val | Yes | ||
| func_str | Yes | ||
| precision | No |