All problems
Second-Order Taylor Approximation
Problem
The second-order Taylor approximation of f about the point a is T(x) = f(a) + f'(a) * (x - a) + 0.5 * f''(a) * (x - a)^2.
Given a polynomial by its coefficient list (index i holds the coefficient of x^i), the expansion point a, and the evaluation point x, return T(x).
Hint
For a quadratic polynomial the second-order approximation is exact.
Test cases
case 1
in: [[0,0,1],1,2]
expected: 4
case 2
in: [[1,1,1],0,1]
expected: 3
case 3
in: [[0,0,0,1],1,1.1]
expected: 1.3300000000000003
case 4
in: [[2],0,5]
expected: 2
Starter codePython
def second_order_taylor(coeffs, a, x):
# Your code here
pass4 test cases · run your code against them in the editor