So I wonder if it is possible to find an equal expression to an expression: $\frac{d}{dx}min(x,n+1)$ which is defined only by the basic operations? All the variables are integers, so it shouldn't matter that as a function, it is discontinuous. (edit: I was corrected by @fleablood, that you can't differentiate of integers. What I meant was that after the differentiation, I'm only interested in the integers, because I'm using them as the lower and upper limit. But I realised that it is irrelevant regarding the problem.)
I was trying to find a formula for the sum of squares with an arbitrary lower limit: $\sum_{k=x}^n k^2$, but could only find $\sum_{k=1}^n k^2= \frac{n(n+1)(2n+1)}{6}$, which works only if the lower limit is equal to 1 (or 0).
I've discovered, that you can express the first more general sum as:
$$\sum_{k=x}^n k^2 = \biggr(\frac{d}{dx}min(x,n+1)\biggr)\biggr(\sum_{k=1}^{-x} k^2+\sum_{k=1}^n k^2 - \sum_{k=1}^{x-1}k^2\biggr)$$
That means that I can express the more general sum of squares using the sums of squares with lower limit equal to 1. Therefore I can rewrite the expression as:
$$\sum_{k=x}^n k^2 = \biggr(\frac{d}{dx}min(x,n+1)\biggr)\biggr(\frac{n(n+1)(2n+1)}{6}-\frac{x(x-1)(2x-1)}{6}\biggr)$$
I am happy with the expression in the right parentheses, but it only works with the alien-looking expression in the left parentheses, so I am trying to find an equal expression that uses only the basic operations.
Since English is not my first language, I might have used some terms incorrectly or awkwardly. But I hope, that the question makes sense. Also I'm really not that good at math, so it is highly probable that I've made an error, or I'm doing it unnecessarily complicated.
(edit 2: So I've found out that you can rewrite the expression in question as:
$$\frac{d}{dx}min(x,n+1)=\frac{1}{2}\biggr(1-\frac{x-n-1}{|x-n-1|}\biggr)$$
- therefore the more general sum of squares can be rewriten as:
$$\sum_{k=x}^n k^2 =\frac{1}{2}\biggr(1-\frac{x-n-1}{|x-n-1|}\biggr)\biggr(\frac{n(n+1)(2n+1)}{6}-\frac{x(x-1)(2x-1)}{6}\biggr)=\frac{(|x-n-1|-x+n+1)(n(n+1)(2n+1)-x(x-1)(2x-1))}{12|x-n-1|}$$
- So my new question: Is this the optimal formula? Meaning, is it the most practical one? When you need to sum squares starting with arbitrary lower limit, is this the formula, you would probably use? - end of edit 2)
Let's denote $\Delta f(x) = f(x+1) - f(x)$, and $ x^{\downarrow m} = \underbrace{x \cdot (x - 1) \cdot \dots \cdot (x - m + 1)}_{m \ times}, $ then
$\Delta (x^{\downarrow m}) = (x+1)^{\downarrow m} - x^{\downarrow m} = (x+1) \cdot x \cdot (x - 1) \cdot \dots \cdot (x - m + 2) - x \cdot (x - 1) \cdot \dots \cdot (x - m + 2) \cdot (x - m + 1) = \underbrace{x \cdot (x - 1) \cdot \dots \cdot (x - m + 2)}_{x^{\downarrow (m-1)}} \cdot \left ( x + 1 - x + m - 1 \right) = m \cdot x^{\downarrow (m-1)}$
$\sum\limits_{x=a}^b \Delta f(x) = \Delta f(a) + \Delta f(a+1) + \dots + \Delta f(b) = f(a + 1) - f(a) + f(a + 2) - f(a + 1) + \dots + f(b+1) - f(b) = f(b + 1) - f(a)$
So: $\sum\limits_{k=1}^n k^{\downarrow r} = \sum\limits_{k=1}^n \frac{\Delta k^{\downarrow (r+1)}}{r+1} = \frac{1}{r+1} \cdot \left( (n+1)^{\downarrow (r+1)} - \underbrace{1^{\downarrow (r+1)}}_{0} \right) = \frac{(n+1) \cdot n \cdot (n - 1) \cdot (n - 2) \cdot \dots \cdot (n - r + 1)}{r+1}$