You will write three tests for functional equations. Each test tries a candidate function on every pair from a grid of numbers. A computer cannot prove that a function solves an equation, but it can show that a candidate fails.
The idea. For the equation , compute the gap for many pairs. If every gap is zero, the candidate passes. The other two equations are and for positive and .
Your tasks.
is_additive(f). Return True when f(x + y) = f(x) + f(y) for every pair from VALUES, within 0.000001.is_multiplicative(f). Do the same for f(x + y) = f(x) * f(y).is_logarithmic(f). Do the same for f(x * y) = f(x) + f(y), using the numbers in POSITIVE.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…