Skip to content
DeepForgeby svx
All problems
EasyCalculusca-001

Numerical Derivative

Problem

Approximate the derivative of the polynomial f(x) = sum(coeffs[i] * x^i) at the point x using central differences:

f'(x) ≈ (f(x + h) - f(x - h)) / (2 * h)

Use h = 1e-6.

Hint

Define a local helper f(t) that evaluates the polynomial at t, then apply central differences.

Test cases

case 1
in: [[0,0,1],3]
expected: 6
case 2
in: [[1,2,3],2]
expected: 14
case 3
in: [[5],10]
expected: 0
case 4
in: [[0,1],7]
expected: 1
Starter codePython
def numerical_derivative(coeffs, x, h=1e-6):
    # coeffs[i] is the coefficient of x^i
    # Your code here
    pass

4 test cases · run your code against them in the editor