Home » Blog » Find a value which minimizes a given sum

Find a value which minimizes a given sum

Let a_1, \ldots, a_n \in \mathbb{R}. Prove

    \[ \sum_{k=1}^n (x-a_k)^2 \]

is minimal when x is the arithmetic mean of a_1, \ldots, a_n.


Proof. Recall that the arithmetic mean of a_1, \ldots, a_n \in \mathbb{R} is given by

    \[ x = \frac{a_1 + \cdots + a_n}{n}. \]

Now, consider the given sum

    \[ \sum_{k=1}^n (x-a_k)^2. \]

To find the minimum we first take the derivative, using the linearity of the derivative over this (finite) sum, (i.e., using that (f+g)' = f' + g'),

    \begin{align*}    \left( \sum_{k=1}^n (x-a_k)^2 \right)' &= \sum_{k=1}^n ((x - a_k)^2)' \\  &= \sum_{k=1}^n 2(x-a_k). \end{align*}

Setting this equal to 0 and solving,

    \begin{align*}  \sum_{k=1}^n 2(x - a_k) = 0 && \implies && 2 \left(\sum_{k=1}^n x - \sum_{k=1}^n a_k \right) &= 0 \\  && \implies && nx - \sum_{k=1}^n a_k &= 0 \\  && \implies && nx &= \sum_{k=1}^n a_k \\  && \implies && x &= \frac{a_1 + \cdots + a_n}{n}. \qquad \blacksquare \end{align*}

Point out an error, ask a question, offer an alternative solution (to use Latex type [latexpage] at the top of your comment):