How to get the summation of a quadratic sequence with O(1) Is there a formula for cumulative or summation of terms in a quadratic equation? I need an O(1) formula since I need to put this into a code. Thanks.
Here's snapshot of my spreadsheet. Currently, I'm just bruteforcing the cumulative value.

 A: Indeed, I have the perfect formula for you!
$$\sum_{r=1}^n 1000r^2+3000=\frac{500}{3}n(n+1)(2n+1)+3000n$$
Ok, now for the derivation.
I'll give a brief explanation of sigma ($\sum$)notation. 
If, for example, we have the series $1+2+3+4...$ tat is the sum of the sequence r and is represented by $\sum_{r=1}^n r$.
There are some results of series which are useful:
$$\sum_{r=1}^n (f(r)+g(r))=\sum_{r=1}^n f(r)+\sum_{r=1}^n g(r)$$
where $f(r)$ and $g(r)$ are functions of $r$, eg $f(r)=r, g(r)=5r^2$.
Another very useful result is the following, where $k$ is a constant:
$$\sum_{r=1}^n kf(r)=k\sum_{r=1}^n f(r)$$
We can apply these rules together with more complicated series.
The following results are standard:
$$\sum_{r=1}^n 1 = n$$
$$\sum_{r=1}^n r^2 = \frac{n(n+1)(2n+1)}{6}$$
These specific results are useful in your query. You are actually asking:
What is the general formula for $\sum_{r=1}^n 1000r^2+3000$?
Let's use the rules we just established:
$$\sum_{r=1}^n 1000r^2+3000=\sum_{r=1}^n 1000r^2+\sum_{r=1}^n 3000=1000\sum_{r=1}^n r^2+3000\sum_{r=1}^n 1=\frac{1000n(n+1)(2n+1)}{6}+3000n=\frac{500}{3}n(n+1)(2n+1)+3000n$$
when simplified. 
I hope that helped!
