You will write functions that find the signed area and the total area of a curve with thin strips, and a test for a curve whose signed area cancels to zero. The checker uses a parabola, a sine wave and a cubic.
The idea. A strip below the axis has a negative height . Adding the heights with their signs gives the signed area. Adding the absolute values gives the total area. A curve can have signed area and still enclose a region.
Your tasks.
signed_area(f, a, b, n). Add f(middle) * width for each of the n strips.total_area(f, a, b, n). Do the same with the absolute value of the height.cancels(f, a, b). Return True when the signed area is within 0.001 of zero and the total area is larger than 0.001.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…