You will write the pieces of the Cauchy-Schwarz inequality and a test for its equality case. The checker uses lists with negative numbers too.
The idea. For two lists and of the same length, . The gap is never negative, and it is zero exactly when the lists are proportional.
Your tasks.
dot(u, v), the sum of the products of matching entries.gap(u, v). Use dot three times.proportional(u, v). Return True when the gap is less than 1e-9.Run your code once to unlock the worked solution.
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…