Problem 440
Medium Curve Sketching

Find the minimum and maximum values of f(x) = sum

Find the minimum and maximum values of $\displaystyle f(x) = \sum_{i=1}^{n}p_{i}\bigl(x-a_{i}\bigr)^{2}$, where $p_{i}\gt 0$.

Explanation of Method

The weighted mean is what minimises the weighted spread.

Step 1: The derivative

The function is a polynomial in $x$, defined everywhere. Differentiating term by term and writing $P = \displaystyle\sum_{i=1}^{n}p_{i}\gt 0$: \[f'(x) = \sum_{i=1}^{n}2p_{i}\bigl(x-a_{i}\bigr) = 2\left(xP-\sum_{i=1}^{n}p_{i}a_{i}\right). \tag{1}\]

Step 2: The critical point

Setting (1) to zero gives a single root, the weighted arithmetic mean of the $a_{i}$: \[x = \bar{a} = \frac{\displaystyle\sum_{i=1}^{n}p_{i}a_{i}}{\displaystyle\sum_{i=1}^{n}p_{i}}. \tag{2}\]

Step 3: It is a minimum

\[ f''(x) = \sum_{i=1}^{n}2p_{i} = 2P\gt 0 \quad\text{for every } x, \tag{3} \]

so $f$ is convex and $\bar{a}$ is the global minimum. Being a quadratic with positive leading coefficient $P$, $f(x)\to+\infty$ as $|x|\to\infty$: there is no maximum.

Step 4: The minimum value in closed form

Expanding, $f(x) = Px^{2}-2Bx+C$ with $B = \displaystyle\sum p_{i}a_{i}$ and $C = \displaystyle\sum p_{i}a_{i}^{2}$, and $\bar{a} = \dfrac{B}{P}$: \[f\bigl(\bar{a}\bigr) = P\cdot\frac{B^{2}}{P^{2}}-\frac{2B^{2}}{P}+C = C-\frac{B^{2}}{P} = \sum_{i=1}^{n}p_{i}a_{i}^{2}-\frac{\left(\displaystyle\sum_{i=1}^{n}p_{i}a_{i}\right)^{2}}{\displaystyle\sum_{i=1}^{n}p_{i}}. \tag{4}\]

This is the weighted variance of the $a_{i}$; it is non-negative, and vanishes exactly when all the $a_{i}$ are equal.

Step 5: Verification

\[p = \bigl(1,2,3\bigr),\ a = \bigl(1,2,4\bigr):\ \bar{a} = \frac{1+4+12}{6} = \frac{17}{6} = 2.8333333\]

\[\text{Formula (4): } \bigl(1+8+48\bigr)-\frac{17^{2}}{6} = 57-48.166667 = 8.8333333 \;\;\checkmark\]

\[\text{Direct: } 1\!\left(\tfrac{11}{6}\right)^{2}+2\!\left(\tfrac{5}{6}\right)^{2}+3\!\left(\tfrac{7}{6}\right)^{2} = 8.8333333 \;\;\checkmark\]


Result

Final answer:

\[\boxed{\,\min_{\mathbb{R}}f = f\bigl(\bar{a}\bigr) = \sum_{i=1}^{n}p_{i}a_{i}^{2}-\frac{\left(\sum_{i=1}^{n}p_{i}a_{i}\right)^{2}}{\sum_{i=1}^{n}p_{i}}, \qquad \bar{a} = \frac{\sum p_{i}a_{i}}{\sum p_{i}}\,}\]

Remark

Remark. This is the least-squares principle in its simplest form: among all candidates $x$, the weighted mean is the one that minimises the total weighted squared deviation. The positivity of every $p_{i}$ is essential — it is what makes $P\gt 0$ and the parabola open upward. With mixed signs the same computation would give a maximum instead, or a degenerate linear function when $P = 0$.