You will write a program that finds the corners of a function from the slopes on its two sides. It checks a list of candidate points and reports the ones where the slopes differ. The checker uses absolute values, a double zero and a product.
The idea. At a candidate point , the left slope is and the right slope is for a tiny . If they differ by more than , the point is a corner.
Your tasks.
slopes(f, a). Return the pair (left, right), with H = 0.000001.is_corner(f, a). Return True when the two slopes differ by more than 0.001.corners(f, candidates). Return the list of candidates at which f has a corner.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…