You will write a numerical second derivative, use its sign to say how a graph bends, and count how often the bend changes on an interval. The checker uses a quartic, a sine and two cubics.
The idea. The second derivative is the change of the slope. For a tiny , estimates it. A positive value means the graph bends up, and a negative value means it bends down.
Your tasks.
second_derivative(f, x). Return (f(x + H) - 2 * f(x) + f(x - H)) / (H * H).bend(f, x). Return "up" when the second derivative is above 0.001, "down" when it is below -0.001, and "neither" otherwise.count_bend_changes(f, a, b). Test 400 points between a and b, shifted half a step from the ends. Count the places where two neighbouring second derivatives have opposite signs.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…
With Standard, you also open 12 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.