You will write three functions that work with a rule given as a Python function: the average rate over an interval, the rate at one moment, and the moment of fastest change. The checker tests several functions.
The idea. The average rate over is . The rate at one moment is the limit of the average as the interval shrinks. A computer cannot take a limit, but a very small interval is close enough. A balanced interval, from to , is the best choice.
Your tasks.
average_rate(f, a, b).rate_at(f, x). Use the interval from x - h to x + h, with h = 1e-6.fastest(f, a, b). Return the point of the grid a, a + step, ..., b where rate_at is largest.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…