Find the number of integral values of $x$ for which
$f(x)=x^2|x-1|+(x-1)^2|x-4|+(x-4)^2|x-9|+.....+(x-2401)^2|x-2500|$
has local minima.
My Attempt $$f(x)=\sum_{m=0}^{49}\left(x-m^2\right)^2\left|x-(m+1)^2\right|$$
It appears that the extrema would appear between $m^2$ and $(m+1)^2$. So how to proceed after this.
A partial answer (I can answer your question, though not with the integer restriction, and the generalization is clear if somewhat offputting). The tl;dr is more enlightening than the gross calculations that I omitted, so here's the summary.
Written in cases, we have $f(x)=$ $$ \begin{cases} -50 x^3+123775 x^2-184333345x+108911329940& x<1 \\ -48 x^3+123773 x^2-184333345 x+108911329940 & 1\leq x<4 \\ -46 x^3+123761 x^2-184333327 x+108911329932 & 4\leq x<9 \\ -44 x^3+123727 x^2-184333151 x+108911329644 & 9\leq x<16 \\ -42 x^3+123659 x^2-184332413 x+108911327052 & 16\leq x<25 \\ -40 x^3+123545 x^2-184330301 x+108911314252 & 25\leq x<36 \\ -38 x^3+123373 x^2-184325451 x+108911269252 & 36\leq x<49 \\ -36 x^3+123131 x^2-184315803 x+108911142244 & 49\leq x<64 \\ -34 x^3+122807 x^2-184298457 x+108910834916 & 64\leq x<81 \\ -32 x^3+122389 x^2-184269529 x+108910171364 & 81\leq x<100 \\ -30 x^3+121865 x^2-184224007 x+108908859164 & 100\leq x<121 \\ -28 x^3+121223 x^2-184155607 x+108906439164 & 121\leq x<144 \\ -26 x^3+120451 x^2-184056629 x+108902222556 & 144\leq x<169 \\ -24 x^3+119537 x^2-183917813 x+108895213788 & 169\leq x<196 \\ -22 x^3+118469 x^2-183728195 x+108884017876 & 196\leq x<225 \\ -20 x^3+117235 x^2-183474963 x+108866730676 & 225\leq x<256 \\ -18 x^3+115823 x^2-183143313 x+108840810676 & 256\leq x<289 \\ -16 x^3+114221 x^2-182716305 x+108802930868 & 289\leq x<324 \\ -14 x^3+112417 x^2-182174719 x+108748809260 & 324\leq x<361 \\ -12 x^3+110399 x^2-181496911 x+108673016588 & 361\leq x<400 \\ -10 x^3+108155 x^2-180658669 x+108568759788 & 400\leq x<441 \\ -8 x^3+105673 x^2-179633069 x+108427639788 & 441\leq x<484 \\ -6 x^3+102941 x^2-178390331 x+108239382180 & 484\leq x<529 \\ -4 x^3+99947 x^2-176897675 x+107991539332 & 529\leq x<576 \\ -2 x^3+96679 x^2-175119177 x+107669162500 & 576\leq x<625 \\ 0 x^3 + 93125 x^2 - 173015625 x + 107254442500 & 625\leq x<676 \\ 2 x^3+89273 x^2-170544375 x+106726317500 & 676\leq x<729 \\ 4 x^3+85111 x^2-167659207 x+106060046492 & 729\leq x<784 \\ 6 x^3+80627 x^2-164310181 x+105226747004 & 784\leq x<841 \\ 8 x^3+75809 x^2-160443493 x+104192895612 & 841\leq x<900 \\ 10 x^3+70645 x^2-156001331 x+102919789812 & 900\leq x<961 \\ 12 x^3+65123 x^2-150921731 x+101362969812 & 961\leq x<1024 \\ 14 x^3+59231 x^2-145138433 x+99471598804 & 1024\leq x<1089 \\ 16 x^3+52957 x^2-138580737 x+97187800276 & 1089\leq x<1156 \\ 18 x^3+46289 x^2-131173359 x+94445950924 & 1156\leq x<1225 \\ 20 x^3+39215 x^2-122836287 x+91171927724 & 1225\leq x<1296 \\ 22 x^3+31723 x^2-113484637 x+87282307724 & 1296\leq x<1369 \\ 24 x^3+23801 x^2-103028509 x+82683519116 & 1369\leq x<1444 \\ 26 x^3+15437 x^2-91372843 x+77270942148 & 1444\leq x<1521 \\ 28 x^3+6619 x^2-78417275 x+70927958436 & 1521\leq x<1600 \\ 30 x^3-2665 x^2-64055993 x+63524947236 & 1600\leq x<1681 \\ 32 x^3-12427 x^2-48177593 x+54918227236 & 1681\leq x<1764 \\ 34 x^3-22679 x^2-30664935 x+44948942428 & 1764\leq x<1849 \\ 36 x^3-33433 x^2-11394999 x+33441890620 & 1849\leq x<1936 \\ 38 x^3-44701 x^2+9761259 x+20204293148 & 1936\leq x<2025 \\ 40 x^3-56495 x^2+32939051 x+5024504348 & 2025\leq x<2116 \\ 42 x^3-68827 x^2+58279901 x-12329340652 & 2116\leq x<2209 \\ 44 x^3-81709 x^2+85931789 x-32110741260 & 2209\leq x<2304 \\ 46 x^3-95153 x^2+116049295 x-54596311308 & 2304\leq x<2401 \\ 48 x^3-109171 x^2+148793743 x-80087324940 & 2401\leq x<2500\\ 50 x^3-123775 x^2+184333345x-108911329940 & x\geq 2500 \\ \end{cases} $$The sole root of $f'$ and hence the minimum value occurs at $r_{50}=\frac{1}{30} \left(\sqrt{9670755955}-70645\right)\approx 923.167$.
I played around with generalizations, namely $ S(x,n) = \sum _{k=0}^{n-1} \left(x-k^2\right)^2 \left| x-(k+1)^2\right| $, to see where the minimum $r_n$ might be. The most promising lead was the coefficient of $x^3$ (which can actually tell us which subinterval, since it increases by two each time): $$ \begin{array}{c|c|c} n & \text{location of minimum, }r_n & \text{ coefficient of }x^3\\ \hline 3 & \frac{1}{3} \left(22-\sqrt{193}\right) & -1 \\ 4 & \frac{56}{11} & 0 \\ 5 & \frac{1}{3} \left(101-\sqrt{5689}\right) & -1 \\ 6 & \frac{417}{34} & 0 \\ 7 & \frac{1}{3} \left(\sqrt{65953}-206\right) & 1 \\ 8 & \frac{516}{23} & 0 \\ 9 & \frac{1}{3} \left(\sqrt{300961}-463\right) & 1 \\ 10 & \frac{2065}{58} & 0 \\ 11 & \frac{1}{3} \left(\sqrt{1006801}-874\right) & 1 \\ 12 & \frac{1}{3} \left(\sqrt{440305}-509\right) & 2 \\ 13 & \frac{1}{3} \left(\sqrt{2746297}-1475\right) & 1 \\ 14 & \frac{1}{6} \left(\sqrt{4445347}-1685\right) & 2 \\ 15 & \frac{1}{3} \left(11 \sqrt{6279}-628\right) & 3 \\ 16 & \frac{1}{3} \left(5 \sqrt{98953}-1295\right) & 2 \\ 17 & \frac{1}{9} \left(\sqrt{14512327}-2867\right) & 3 \\ 18 & \frac{1}{6} \left(\sqrt{20025211}-3769\right) & 2 \\ 19 & \frac{1}{9} \left(\sqrt{28270807}-4136\right) & 3 \\ 20 & \frac{1}{6} \left(\sqrt{9712915}-2243\right) & 4 \\ 21 & \frac{1}{3} \left(\sqrt{5717703}-1909\right) & 3 \\ 22 & \frac{1}{12} \left(\sqrt{68851741}-6179\right) & 4 \\ 23 & \frac{1}{9} \left(\sqrt{88641703}-7676\right) & 3 \\ 24 & \frac{1}{6} \left(\sqrt{28988443}-4121\right) & 4 \\ 25 & \frac{1}{15} \left(\sqrt{149183395}-8785\right) & 5 \\ 26 & \frac{1}{12} \left(\sqrt{187158757}-10711\right) & 4 \\ 27 & \frac{1}{15} \left(\sqrt{236709955}-11380\right) & 5 \\ 28 & \frac{1}{6} \left(31 \sqrt{75811}-6811\right) & 4 \\ 29 & \frac{1}{15} \left(\sqrt{363114331}-14429\right) & 5 \\ 30 & \frac{1}{6} \left(\sqrt{49709523}-5069\right) & 6 \\ 31 & \frac{1}{15} \left(\sqrt{541056739}-17968\right) & 5 \\ 32 & \frac{1}{9} \left(\sqrt{164689303}-9448\right) & 6 \\ 33 & \frac{1}{21} \left(\sqrt{794838709}-19789\right) & 7 \\ 34 & \frac{1}{18} \left(\sqrt{946968835}-23123\right) & 6 \\ 35 & \frac{1}{3} \left(\sqrt{23093653}-3454\right) & 7 \\ 36 & \frac{1}{3} \left(\sqrt{37021755}-4654\right) & 6 \\ 37 & \frac{1}{21} \left(\sqrt{1578794893}-29153\right) & 7 \\ 38 & \frac{1}{24} \left(5 \sqrt{74305849}-30341\right) & 8 \\ 39 & \frac{1}{21} \left(\sqrt{2163532165}-34750\right) & 7 \\ 40 & \frac{1}{6} \left(\sqrt{157945723}-9031\right) & 8 \\ \end{array} $$
I might play around with this more; apologies if the edits keep popping up. Perhaps more can be said about the coefficients of the $0^{th}-2^{nd}$ order terms, maybe even written as a function of the upper limit of summation. Hope that helps!