# What value of x yields the minimum value of this sum?

What value of x yields the minimum value of the sum $$| x- 2^0| + | x - 2^1 | + ... | x - 2^{10}|$$ ?

First, I tried 186, adding up the two's as if they were geometric series while completely forgetting about the absolute value part of the equation. Then, I figured out that 1 yields a smaller sum than 186, and I was wondering if there was an efficient way to solve, rather than plotting the critical points since 1,024 would be too big to plot. Am I wrong in doing that, or is graphing it the most efficient way of solving it? I have not graphed it yet.

• What have you tried? Jan 20 '20 at 2:04
• Welcome to Stackexchange. You'll find that simple "Here's the statement of my question, solve it for me" posts will be poorly received. What is better is for you to add context (with an edit): What you understand about the problem, what you've tried so far, etc.; something both to show you are part of the learning experience and to help us guide you to the appropriate help. You can consult this link for further guidance. Jan 20 '20 at 2:05
• What is $x$? An integer? A real number? Something else? Jan 20 '20 at 2:06

The min of $$f(x)=\sum_{k=0}^{n} |x-x_k| =n(M.D)$$ (M.D means the mean deviation of $$x_k$$ w.r.t. $$x$$) is attained at the median $$M$$ of the sequence $$x_k, k \in [0,k]$$. The median of the sequence $$2^0,2,^1,2^3,....2^{10}$$ is $$M=2^5=32$$. Hence the answer is $$x=32$$.
• I was wrong earlier. Anyway I just checked the graph. The min of $\sum_{n=0}^{N}\left|x-2^{n}\right|$ When $N=10$ is $(32,1953)$. Generally the $x$ coordinate of the min is $x=\sqrt{2^N}$ when $N$ is even. When $N$ is odd the min $x$ values are the interval $[2^\frac{N-1}{2},2^\frac{N+1}{2}]$ Jan 20 '20 at 2:53