Skip to content
DeepForgeby svx
All problems
HardCalculusca-374

Quadratic Taylor Linearization Error

Problem

For f(x) = x^T A x, the error of the first-order Taylor approximation at x0 evaluated at x is exactly d^T A d, where d = x - x0 and A must be symmetrized.

Given A as nested rows, x0, and x, return f(x) - f(x0) - grad f(x0) dot d.

Hint

For a quadratic the residual equals d^T A d regardless of the base point.

Test cases

case 1
in: [[[1,0],[0,1]],[0,0],[1,2]]
expected: 5
case 2
in: [[[0,1],[0,0]],[1,1],[2,3]]
expected: 2
case 3
in: [[[2,0],[0,2]],[0,0],[0,1]]
expected: 2
Starter codePython
def quadratic_taylor_linearization_error(a, x0, x):
    # Your code here
    pass

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