This is probably simple (if not, my apologies beforehand), but I have the following formula:
$$f(0) = 2$$ $$f(x) = 6x + 2 + f(x -1) \; \text{ where } x \in \mathbb{N}_{\gt 0}$$
The formula actually represents a quadratic performance in a certain algorithm, but the fact that it is quadratic is not immediately clear.
I was considering that the sum of natural numbers can be expressed as $$\sum_{k=1}^n k= \frac{n(n+1)}{2}$$, which makes the quadratic factor apparent. I figured it shouldn't be too hard to express the above recursive function similarly in a non-recursive way, showing or proofing that it is indeed quadratic.
I'd be interested in how to deduce the steps to get to the formula, instead of only getting the (right) answer.
Note: the series expressed here is: $2, 10, 24, 44, 70, 102, 140....$
$$f(0)=6(0)+2$$
$$f(1)-f(0)=6(1)+2$$
$$f(2)-f(1)=6(2)+2$$
$$\vdots$$
$$f(x)-f(x-1)=6(x)+2$$
Adding all these equations,
$$\begin{align}f(x)&=\sum_{i=0}^x (6x+2)\\&=\left(\sum_{i=1}^x6x\right)+2(x+1)\\&=3x(x+1)+2(x+1)\\&=(x+1)(3x+2)\end{align}$$