Finding the no. of points at which $f$ is non-differentiable and the no. of integral points for which $f$ is minimum. If $$f(x) = |x| + |x - 1| + |x - 3| + |x - 6| + \cdots + |x - (1 + 2 + \cdots + 101)|$$ for all $x \in \mathbb R$ and $m,n$ are respectively the number of points at which $f(x)$ is non differentiable and the number of integral points for which $f(x)$ is minimum, then find the value of $(m+n-10)/18$.
I've graphed a part of the function, and I observe that when I graph in odd number of terms, I get minima at only one point, while for even number of terms I get a constant line as the minima which has in its range half the number of integers as the number of terms in the graphed functions. But I have no idea why this happens.
Do answer keeping in mind that I'm only a high school student :) I have looked for this everywhere and couldn't find any insight. Any help is much appreciated.
 A: When you see a relatively big number, like $101$, it's useful to generalise first. So let $r$ be a natural number, and $$ f_r(x) := |x| + |x-1| + \dots |x - (1+\dots + r)| \\= \sum_{k = 0}^r |x - k(k+1)/2| =: \sum_{k = 0}^r |x - a_k|,$$ where $a_k = k(k+1)/2$. Note that the $a_k$ are increasing.
We know that the aboslute values will have some interesting feature at the $a_k$s. So imagine drawing vertical stumps at each of the $a_k$ on the x axis, which gives us a total of $r+2$ regions. 
In the left-most region, i.e. $\{x < 0\}$, all the absolute values resolve to $a_k - x$, so the function has slope $-(r+1)$ in the interior of this region, and it's decreasing in this range. Now move to the next region. $|x|$ now resolves to $+x$, everything else is the same. So we get slope $-(r+1) + 2 = -(r-1) < 0$. Still decreasing. 
Continuing this way, you will notice that (for odd $r$) for the region starting at $a_{(r-1)/2}$ and ending at $a_{(r+1)/2}$, the number of $+x$-terms exactly balance the number of $-x$ terms, so the function has slope $0$ in the interior of this region. This is our large flat region where the function is minimum. After this region, the $+x$ terms will start outnumbering the $-x$ terms, and the function will increase. (If $r$ were even, we'd have a single point as the minima. Can you see why?)
So, where does this flat region start? At $a_{(r-1)/2}$. Ends at $a_{(r+1)/2}.$ Note that both these points, which are natural numbers, are also minima, since the function is continuous. So the number of natural number points which attain the minimum is $a_{(r+1)/2} - a_{(r-1)/2} + 1$. This is equal to $$ \frac{(r+1)(r+3)}{8} - \frac{(r-1)(r+1)}{8} + 1 = \frac{r+3}{2}.$$
So, for this question, $n = 104/2 = 52$.
On the other hand, clearly at each of the points $0, a_1, \dots, a_{r},$ the function has a non-differentiability - the slope jumps by $2$. So the number of points $m$ is $r+1 = 102$ for us. 
This means, of course, that $m+n - 10 = 144 = 8 \times 18$. 
A: The absolute value function is continuous, with continuous derivative everywhere except at the point where the value is zero. We also know that the derivative of $|x|$ is either $1$ or $-1$. So the first hint that I've mentioned in the comments says that $f(x)$ is not differentiable when the value of any of the terms is $0$, You have $102$ such values, so $m=102$.
Now let's concentrate on finding the minimum. We know that such a minimum exists because $f(\infty)=f(-\infty)=\infty$, $f(0)=0+1+3+...+(1+2+...+101)<\infty$, and the function is continuous. We don't know if there is only one minimum or more than that. When you expand the absolute value, you have $|x|=-x$ if $x<0$ and $|x|=x$ if $x>0$. Whys is this important? Let's choose $x>1+2+...+101$. Then all the absolute values in the $f(x)$ are on the positive side for the arguments and $$f(x)=x+x-1+...+x-(1+...+101)=102x+C_0$$
Here $C_0$ is just a number. So in this case the slope is $102$, so the minimum on the segment from $1+...+101$ to infinity must be at the beginning. Now let's compare it to the previous interval. $1+...+100<x<1+...+101$. In this case you will need to change sign in the last term. Then $$f(x)=x+x-1+...+(x-(1+...+100))-(x+(1+...+101))=100x+C_1$$.
Obviously this is an increasing function, so the minimum is achieved at the beginning of the interval. You can continue this procedure. At every step you decrease the coefficient of $x$ by $2$. You should be able to figure out when that coefficient is $0$ (between $1+...+50$ and $1+...+51$). In that interval, $f(x)$ is constant. If you go to earlier intervals, the coefficient of $x$ will be negative, so on those segments the function is decreasing.
So the number of integers when the function is minimum is $52$ (you need to include the ends of the interval). Therefore $$m+n-10=102+52-10=144$$
Note: If the number of intervals is odd, you would have a single number as minimum. The slope on one side is positive, on the other is negative. You would not get a constant interval
