What does bounding a function from both sides buy you, and why can Theta throw away every term but the dominant one?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Theta asks two things of the same g: c0 times g(x) stays at or above f(x) from x0 on, and c1 times g(x) stays at or below f(x) from x1 on. Check each condition at every whole number from its own threshold up to and including 1000 (all() and range() may help); the video's f () and g () are already defined. Define pinned(f, g, c0, x0, c1, x1) returning True only when both conditions hold.
# the video's cost function and its bounding function
def f(x):
return 3 * x**2 - 20 * x - 1
def g(x):
return x**2