You will write three small functions that check a claimed identity on many angles: one finds the worst miss between the two sides, one says whether the identity holds, and one finds an angle where it fails.
The idea. For a true identity, the two sides agree to within rounding error, about . A tolerance of is safe. For a false identity, some angle shows a miss far bigger than that.
Your tasks.
worst_miss, return the largest absolute difference between the two arrays.holds, return True when the two arrays agree everywhere within 1e-9, and False otherwise.first_counterexample, return the first angle where the sides differ by more than 1e-9, or None when there is none.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…