# $E(x)= |x|-|x+1|+|x+2|-|x+3|+\dots+|x+2016|$. Find the minimum value of $E$.

Can any one help me finding the minimum value of the following expression: $$E(x)= |x|-|x+1|+|x+2|-|x+3|+\dots+|x+2016|$$ where $$x$$ is a real number.

• Have you seen what the graph looks like? Try with fewer terms (like three, or five), and see what happens. Aug 3, 2019 at 20:25

1) If $$x \geq 0$$:

$$E(x) = (|x| - |x+1|) + (|x+2| - |x+3|) + ... + (|x + 2014| - |x+2015|) + |x + 2016| = \frac{2016}{2}(|x| - |x+1|) + |x + 2016|,$$

since $$\forall x \in [0, \infty) \hspace{.2cm} (|x| - |x+1|) = (|x+2| - |x+3|) = ... = (|x + 2014| - |x+2015|) = -1$$.

I.e. $$x \geq 0 \Rightarrow E(x) = 1008 \times (-1)+ |x + 2016| \Rightarrow\underset{x \in [0, \infty)} \min E(x) = E(0) = 1008.$$

2) If $$x \leq - 2015$$:

$$E(x) = (|x| - |x+1|) + (|x+2| - |x+3|) + ... + (|x + 2014| - |x+2015|) + |x + 2016| = \frac{2016}{2}(|x| - |x+1|) + |x + 2016|,$$

$$\forall x \in (-\infty, -2015] \hspace{.2cm} (|x| - |x+1|) = (|x+2| - |x+3|) = ... = (|x + 2014| - |x+2015|) = -1$$.

I.e. $$x \geq 0 \Rightarrow E(x) = 1008 + |x + 2016| \Rightarrow \underset{x \in (-\infty, -2015]} \min E(x) = E(-2016) = 1008.$$

3) If $$- 2015 < x < 0$$:

$$\forall n \in \{1,...,2016\} \hspace{.2cm} n+1 <|x| \Rightarrow |x + n| = |x| - n \wedge |x + n + 1| = |x| - n - 1$$ I.e. $$|x + n| - |x + n + 1| = 1.$$ (i)

Following the same logic:

$$\forall n \in \{1,...,2016\} \hspace{.2cm} n >|x| \Rightarrow |x + n| = n - |x| \wedge |x + n + 1| = n + 1 - |x|$$ I.e. $$|x + n| - |x + n + 1| = -1.$$ (ii)

3.1) If $$- 2015 < x < 0 \wedge \lceil x \rceil$$ - even:

$$\lceil x \rceil := k$$ $$\Rightarrow x \in [k, k-1]$$.

$$\forall n < |k| \hspace{.2cm} k-even \Rightarrow n+1 < k. \hspace{.2cm}$$ Here (i) implies $$|x+n|−|x+n+1|=1.$$ I.e there are $$\frac{k}{2}$$ terms in $$E(x)$$ that behave as in 2).

$$n = k \hspace{.2cm} \Rightarrow |x+n| = |x| - k \wedge |x+ n + 1| = k + 1 - |x|.\hspace{.2cm}$$ Here $$|x+n|−|x+n+1| = |x| - k - (k + 1 - |x|) = 2(|x| - k) - 1 =:r.\hspace{.2cm}$$. $$k - even \Rightarrow r \in [-1, 1).\hspace{.2cm}$$ Compared to 2) this term is smaller.

$$\forall n > |k| \hspace{.2cm} \wedge n-even \hspace{.2cm}$$ (ii) applies. Thus here $$|x+n|−|x+n+1|=-1.$$ There are $$1008 - 1- \frac{k}{2}$$ terms in $$E(x)$$ that switch sign compared to 2).

Thus for k - even we have: $$E(x) = \frac{k}{2} \times 1 + r + (1007- \frac{k}{2}) \times (-1) +|x+2016|= |x+2016| + k-1007+r = 2016 - k - (|x| - k) + k - 1007 + r = 1009 + \frac{r}{2} \geq 1008,$$

where $$|x| = k \Leftrightarrow E(x) = 1008.$$

3.2) If $$- 2015 < x < 0 \wedge \lceil x \rceil$$ - odd:

$$n \leq k - 3 \hspace{.2cm} \wedge n-even \hspace{.2cm} \Rightarrow |x+n|−|x+n+1|=1 \hspace{.1cm}$$ by (i). Thus up to and including |x+(k-3)|−|x+(k-2)| all terms behave as in 2). There are a total of $$\frac{k-1}{2}$$ such terms.

$$n > k \hspace{.2cm} \wedge n-even \hspace{.2cm} \Rightarrow |x+n|−|x+n+1|=-1 \hspace{.1cm}$$ by (ii). From and including |x+ k + 1|−|x+k+2| all terms change sign. There are a total of $$1008 - \frac{k+1}{2}$$ such terms.

$$n = k-1 \Rightarrow \hspace{.1cm} |x+n| = |x+(k-1)| = |x| - (k-1) \wedge |x+n+1| = |x+k| = |x| - k \hspace{.1cm} \Rightarrow |x+n| - |x+(k-1)| = 1.$$ Thus in total there are $$1008 - \frac{k+1}{2}$$ terms that switch sign compared to 2) and $$\frac{k+1}{2}$$ that don't.

Thus for k - odd we have: $$E(x) = \frac{k+1}{2} \times 1 + (1008 - \frac{k+1}{2}) \times (-1) + |x + 2016| = 2016 -|x| - 1008 + k+1 = 1009 - |x|+ k+1 = 1008 + k+1-|x| \geq 1009.$$

I.e. $$\underset{x \in \mathbb{R}}\min E(x) = 1008. \underset{x \in \mathbb{R}}{\operatorname{argmin}} E(x) = \{-2k| k \in \{0, ... 1008\}\}$$

• $\forall x \in \mathbb{R}, |x| - |x+1|)= |x+2| - |x+3|$，take $x=-1/2$. Aug 4, 2019 at 2:05
• True, which means $\forall x \in (-2016, 0) E(x) \neq 1008 + |2016 + x|$ Aug 4, 2019 at 5:14
• @ Rieman I have corrected the proof and checked it for all nonpositive integers with R, would you please take a look? Aug 4, 2019 at 18:48
• Really Nice answer! Aug 5, 2019 at 2:31

Note that \begin{align}E(x+2)&=|x+2|-|x+3| \mp\cdots+|x+2016|-|x+2017|+|x+2018|\\&=E(x)-|x|+|x+1|-|x+2017|+|x+2018|\end{align} and $$|x+1|-|x|=\begin{cases}1&x\ge 0\\-1&x\le -1\\2x+1&-1\le x\le0\end{cases}$$ $$|x+2017|-|x+2018|=\begin{cases}1&x\ge -2017\\-1&x\le -2018\\2(x+2017)+1&-2018\le x\le2017\end{cases}$$ From this, $$\tag1E(x+2)\le E(x) \qquad \text{for }x\le -1$$ $$\tag2E(x+2)\ge E(x) \qquad \text{for }x\ge -2017$$ so that the minimum of $$E$$ on the interval $$[-2017,-1]$$ (which exists because $$E$$ is continuous and the interval is compact) is also the global minimum of $$E$$. Combining $$(1)$$ and $$(2)$$, $$\tag3E(x+2)= E(x) \qquad \text{for }-2017\le x\le -1$$ so that we can look for the minimum on any interval of length $$2$$ within $$[-2017,-1]$$, for example on $$[-3,-1]$$. There, $$E(x)=|x|-|x+1|+|x+2|-(x+3)+(x+4)\mp\cdots+(x+2016)=|x|-|x+1|+|x+2|+const$$ and the rest is easy.

If you look at the graph of $$E(x)= |x|-|x+1|+|x+2|-|x+3|+\dots+|x+n|$$, you can notice that if $$n$$ is even (our case), then the graph of $$E(x)$$ is symmetric to the line $$x=-\frac{n}{2}$$. In fact here the graph of $$E(x)= |x|-|x+1|+|x+2|-|x+3|+|x+4|$$:

To find the minimum value I have to set $$x\geq0$$, so: $$E(x)= |x|-|x+1|+|x+2|-|x+3|+\dots+|x+2016|=x-x-1+x+2-x-3+\dots+x+2016$$ Removing absolute values, I obtain: $$2+4+\cdots+2016-(1+3+5+\cdots+2015)=A-B$$. I have now two aritmetic series; their values are:$$A=\frac{2016}{2}\cdot(4+1007\cdot2)=1008\cdot2018$$ and $$B=\frac{2016}{2}\cdot(2+1007\cdot2)=1008\cdot2016$$.

Now I obtain: $$A-B=1008\cdot2018-1008\cdot2016=1008\cdot2=2016$$.

I hope it has helped you...

• thanks for the answer. I have one question, why you set x as positive to find the minimum? Aug 3, 2019 at 21:34
• In that way I have removed the absolute values; if not it would have been more complicated to continue. Aug 3, 2019 at 21:40
• X doesn't simplify away because E(x) has 2017 summands which all contain x (n goes from 0 to .2016). Aug 3, 2019 at 21:51
• Sorry, my error. The result doesn't change, anyway. Aug 3, 2019 at 21:55
• It does, it depends on x now. Aug 3, 2019 at 22:00

Calling $$f(x) = |x|-|x+1|$$ we have

$$E_n(x) = \sum_{k=0}^{k=n}f(x+2k)$$

and

$$-(n+1) \le E_n(x) \le n+1$$