All problems
Inflection Point of a Cubic
Problem
Find the x-coordinate of the inflection point of f(x) = a*x^3 + b*x^2 + c*x + d.
The second derivative is f''(x) = 6*a*x + 2*b, which vanishes at x = -b / (3*a). Return None when a == 0, since then the function is not a cubic.
Hint
Set the second derivative to zero and solve the resulting linear equation.
Test cases
case 1
in: [1,-3,0,0]
expected: 1
case 2
in: [2,6,0,0]
expected: -1
case 3
in: [-1,0,0,0]
expected: 0
case 4
in: [0,5,1,0]
expected: null
Starter codePython
def inflection_point(a, b, c, d):
# Return None when a == 0
# Your code here
pass4 test cases · run your code against them in the editor