You will write three functions that find the greatest or least value of a function on an interval by trying many points, and use them on a fence problem. The checker compares the answers with the results of calculus.
The idea. A computer can find an extreme value by trying a fine grid of values of and keeping the best one. The result is close to the exact answer when the grid is fine. The calculus answer lets us check it.
Your tasks.
greatest(f, a, b). Try 10001 equal steps from a to b and return the pair (x, f(x)) with the largest value, rounded to 3 decimal places.least(f, a, b). In the same way, return the pair with the smallest value.best_pen(L). A pen against a wall has fence on three sides, with each short side x and the long side L - 2 * x. Return the pair (x, area) with the greatest area, using greatest.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…