The two constants behind big-O
Claude prompt
This page was generated by Claude Code from the following prompt (with additional prompting):
let's make a js demo for the definition of big O. have sliders for c and n_0 with f(n) = 3n^2 + 5n + 2 and maybe a drop down or another way to select g
Definition: \(f(n) = O(g(n))\) as \(n \to \infty\) if there exist positive constants \(c\) and \(n_0\) such that \[ 0 \le f(n) \le c\,g(n) \quad\text{for all } n \ge n_0 \]
In other words, if we can choose \(c\) and \(n_0\) to eliminate all red (including to the right beyond the edge of the plot), then \(f(n) = O(g(n))\).
fixed
\(f(n) = n^2 + 12 n \sin n + 50\)