You will write three functions that work with any smooth function given as a Python function: the derivative at a point, the critical points on an interval, and the kind of a critical point. The checker tests several functions.
The idea. The derivative can be found from a very short balanced interval. A critical point lies where changes sign, so we scan a fine grid and look for a change of sign between neighbouring points. The first derivative test then looks at the sign of just before and just after the point.
Your tasks.
slope(f, x). Use the interval from x - h to x + h, with h = 1e-6.critical_points(f, a, b). The list xs holds a fine grid of points on . Return the point half way between two neighbouring grid points where slope changes sign, rounded to 2 decimal places.classify(f, c). Return "maximum", "minimum" or "neither" from the signs of slope at c - 0.01 and c + 0.01.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…