finite_differences
Approximate first and second derivatives of a function at a point using forward, backward, and central differences, and compare each numerical result against the exact SymPy derivative to assess error.
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.
Returns: Dict with the exact and numerical derivatives and their errors.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| h | No | ||
| x_val | Yes | ||
| func_str | Yes | ||
| precision | No |