You will write three functions that explain why a region must be split where the curves cross. The checker uses the curves and , which cross three times.
The idea. A signed integral of lets a lobe below the other curve count as negative, so lobes can cancel. Making every strip positive with abs gives the true area. Each crossing shows up as a change of sign of .
Your tasks.
signed_area(f, g, a, b). Add 4000 strips of height g(x) - f(x), using the middle of each strip.total_area(f, g, a, b). Do the same, but take the absolute value of each strip height.count_crossings(f, g, a, b). Count how many times the sign of f(x) - g(x) changes from one strip to the next.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…