All problems
Partial Derivatives of a Quadratic Form
Problem
For f(x, y) = a * x^2 + b * x * y + c * y^2, return the gradient [df/dx, df/dy] evaluated at (x, y).
df/dx = 2 * a * x + b * y and df/dy = b * x + 2 * c * y.
Hint
Treat the other variable as a constant when differentiating.
Test cases
case 1
in: [1,2,3,1,2]
expected: [6,14]
case 2
in: [0,0,1,5,-3]
expected: [0,-6]
case 3
in: [2,-1,0,0,0]
expected: [0,0]
case 4
in: [1,1,1,-2,4]
expected: [0,6]
Starter codePython
def partial_derivatives(a, b, c, x, y):
# Return [df_dx, df_dy]
# Your code here
pass4 test cases · run your code against them in the editor