# How to find the best quadratic approximation to a cubic function between two of its (real) roots

Consider a real cubic polynomial function with three real roots. By applying a translation and horizontal and vertical dilations, we can transform it to the form $$p_r(x) = x (x - 1) (x - r)$$ for some constant $$a$$.

1. Which quadratic polynomial $$q(x) = A x^2 + B x + C$$ best approximates $$p$$ on the interval $$[1, r]$$ bounded by its larger two roots?
2. What terms asymptotically dominate $$A, B, C$$ regarded as functions of $$r$$ as $$r \to \infty$$?

The aim of asking (and self-answering) this question is to illustrate the ideas and computational techniques used in my answer to another, similar question. In that question, $$p$$ and $$[1, r]$$ are replaced with another $$1$$-parameter family of functions $$f$$ and intervals. However, many of the computations in that answer (e.g., the explicit expression for the squared $$L^2$$ norm of the differences $$f - q$$) were too complicated to typeset. The class of functions in this problem makes the computations more presentable.

As in the motivating question, we interpret "best approximates $$p_r$$ on the interval" as minimizing the (squared) $$L^2([1, r])$$ norm of $$q - p_r$$. This quantity is \begin{align} M :\!&= \int_1^r (q(x) - p_r(x))^2 dx \\ &= \int_1^r [(A x^2 + B x + C) - x (x - 1) (x - r)]^2 \\ &= \frac{1}{105} r^7 + \frac{1}{30} (2 A - 1) r^6 + \frac{1}{30} (6 A^2 - 3 A + 3 B + 1) r^5 \\ &\qquad\qquad + \frac{1}{6} (3 A B - B + C) r^4 + \frac{1}{3} (2 A C + B^2 - C) r^3 \\ &\qquad\qquad + \frac{1}{30} (30 B C - 1) r^2 + \frac{1}{30} (30 C^2 + 3 A + 5 B + 10 C + 1) r + K \end{align} for some (irrelevant) constant $$K$$. In particular, $$M$$ is quadratic in $$A, B, C$$.
To minimize this quantity as a function of $$M$$, we proceed as usual by finding its critical points $$(A, B, C)$$, that is, solving $$\frac{\partial M}{\partial A} = \frac{\partial M}{\partial B} = \frac{\partial M}{\partial C} = 0.$$
Computing directly gives, for example, $$0 = \frac{\partial M}{\partial C} = \frac{1}{6} r^4 + \frac{1}{3} (2 A - 1) r^3 + B r^2 + \frac{1}{3} (6 C + 1) + \frac{1}{6}(-4 A - 6 B - 12 C - 1),$$ and rearranging gives $$\frac{2}{3}(r^3 - 1) A + (r^2 - 1) B + 2 (r - 1) C = -\frac{1}{6} (r^4 - 2 r^3 + 2 r - 1) .$$ Repeating this manipulation for the other two partial derivatives yields a linear system of three (independent) equations in $$A, B, C$$, and the unique solution (which must give a minimum of $$M$$) is $$A = \frac{1}{2} (r + 1), \qquad B = \frac{1}{5} (-3 r^2 - 4 r - 3), \qquad C = \frac{1}{20} (r^3 + 9 r^2 + 9 r + 1) ,$$ giving the best approximation $$\color{red}{\boxed{q(x) = \frac{1}{2} (r + 1) x^2 + \frac{1}{5} (-3 r^2 - 4 r - 3) x + \frac{1}{20} (r^3 + 9 r^2 + 9 r + 1)}} .$$ Peeling off the dominant terms we can write $$A = \frac{1}{2} r + O(1), \qquad B = -\frac{3}{4} r^2 + O(r), \qquad C = \frac{1}{20} r^3 + O(r^2) ,$$ giving the simpler quadratic approximation $$\frac{1}{2} r x^2 - \frac{3}{5} r^2 x + \frac{1}{20} r^3 .$$
This graph shows plots over $$[1, r]$$ of the cubic function $$p$$ (dark red), the best approximation $$q$$ (blue), and the simple approximation (green) for $$r = e^4$$.