UNSW MathSoc Championship Q5

Algebra Level 3

Find the value of c R c \in \mathbb{R} for which the quantity n = 1 2017 n c \displaystyle \sum_{n=1}^{2017} |n - c| is minimal.


The answer is 1009.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Zach Abueg
Dec 20, 2017

For a set S S with n n elements such that s 1 < s 2 < < s n s_1 < s_2 < \cdots < s_n , s S x s \displaystyle \sum_{s \ \in \ S} |x - s| is minimized when x x is the median of S S .

Let's show this intuitively before proving it rigorously.

Intuition

Imagine the given values as trees along a road. The quantity you are trying to minimize is the sum of distances between you and each of the trees.

Suppose that you are standing at the median, and you know the current value of the sum. How will it change if you move in either direction? Note that regardless of which direction you choose, in each moment you will be moving away from at least half of the trees, and towards at most half of the trees. Therefore, the sum of distances can never decrease -- and that means the sum of distances at the beginning had to be optimal.

Proof

Suppose that the set S S has n n elements, s 1 < s 2 < < s n s_1 < s_2 < \cdots < s_n . If x < s 1 x < s_1 , then

f ( x ) = s S x s = s S s x = s S ( s x ) = k = 1 n ( s k x ) \displaystyle \begin{aligned} f(x) = \sum_{s \ \in \ S} |x - s| = \sum_{s \ \in \ S} |s - x| = \sum_{s \ \in \ S} \left(s - x\right) = \sum_{k = 1}^{n} \left(s_k - x\right) \end{aligned}

As x x increases, each term of f ( x ) f(x) decreases until x x reaches x 1 x_1 , so f ( s 1 ) < f ( x ) f(s_1) < f(x) for all x < s 1 x < s_1 .

Now suppose that s k x x + d s k + 1 s_ k \leq x \leq x+d \leq s_k + 1 . Then

f ( x + d ) = i = 1 k ( x + d s i ) + i = k + 1 n ( s i ( x + d ) ) = d k + i = 1 k ( x s i ) d ( n k ) + i = k + 1 n ( s i x ) = d ( 2 k n ) + i = 1 k ( x s i ) + i = k + 1 n ( s i x ) = d ( 2 k n ) + f ( x ) \displaystyle \begin{aligned} f(x + d) & = \sum_{i \ = \ 1}^{k} \left(x + d - s_i\right) + \sum_{i \ = \ k + 1}^{n} \left(s_i - (x + d)\right) \\ & = dk + \sum_{i \ = \ 1}^{k} \left(x - s_i\right) - d(n - k) + \sum_{i \ = \ k + 1}^{n} \left(s_i - x\right) \\ & = d(2k - n) + \sum_{i \ = \ 1}^{k} \left(x - s_i\right) + \sum_{i \ = \ k + 1}^{n} \left(s_i - x\right) \\ & = d(2k - n) + f(x) \end{aligned}

so f ( x + d ) f ( x ) = d ( 2 k n ) f(x + d) - f(x) = d(2k - n) . This is negative if 2 k < n 2k < n , zero if 2 k = n 2k = n , and positive if 2 k > n 2k > n . Thus, on the interval [ s k , s k + 1 ] \left[s_k, s_{k+1}\right] ,

f ( x ) is { decreasing, if 2 k < n constant, if 2 k = n increasing, if 2 k > n \displaystyle f(x) \ \text{is } \begin{cases} \text{decreasing, } & \text{if } 2k < n \\ \text{constant, } & \text{if } 2k = n \\ \text{increasing, } & \text{if } 2k > n \end{cases}

In particular, we note that when 2 k = n 2k = n , the sum stays constant. What this translates to for our tree analogy is that the sum of the distances does not "tend" toward one direction or another. Finally, we note that since 2 k = n 2k = n , k k is the median of our set S S .

Thus, we have proven that for a set S S with n n elements such that s 1 < s 2 < < s n s_1 < s_2 < \cdots < s_n , s S x s \displaystyle \sum_{s \ \in \ S} |x - s| is minimized when x x is the median of S S . Now let f ( x ) = n = 1 2017 x n \displaystyle f(x) = \sum_{n \ = \ 1}^{2017} |x - n| . f ( x ) f(x) is minimized when x x is the median of the set S = { 1 , 2 , 3 , 2016 , 2017 } S = \{1, 2, 3, \ldots 2016, 2017\} . Since S S is a uniform distribution, the median equals the mean of the set, so the median is x = 1 + 2017 2 = 1009 \displaystyle x = \frac{1 + 2017}{2} = \boxed{1009} .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...