Finding the function for a sequence using differences I am trying to find a function generating/suitable for the following sequence:
${2,6,12,20,30,42,56...}$
The first order differences are:
$4, 6, 8, 10, 12, 14...$
and the second order differences are:
$2, 2, 2, 2, 2, 2...$
this means that:
$y''= 2 \implies y' = 2\cdot x + c$ and we can see that for $c = 2$ we can get the correct numbers i.e. the first order differences (replacing starting from $x = 1$). So $y' = 2\cdot x + 2$
This means that $y = x^2 + 2\cdot x + c$
But I can't find any value of $c$ that would give the original sequence.
Now I see that $y'$ could also be $y' = 2\cdot x + 4$ as it gives the correct numbers if we replace starting from $x = 0$ but then we have $y = x^2 + 4\cdot x + c$ and I again can't find any $c$ that matches the original sequence.
What am I doing wrong here?
 A: You start with the sequence $y=2,6,12,20,30,42,56$ when $x=1,2,3,\dots$.
You have found that $y(2)-y(1)=4, y(3)-y(2)=6, y(4)-y(3)=8,\dots$, but this is not the same as finding $y'(1), y'(2),\dots$, because the value of $y'$ is not constant over these intervals.
In fact, since $y'$ changes linearly (for $y$ is a quadratic), you have actually found $y'(1.5),y'(2.5),y'(3.5),\dots=4,6,8,\dots$ i.e. these numbers $4,6,8,\dots$ are the average rate of change across the intervals $[1,2],[2,3],\dots$, which happens to be the exact rate of change at the midpoint of the interval.
For $y''$, which is constant everywhere, this nuance does not matter: $y''=2$ and you have correctly concluded that $y$ will have a term of $x^2$ (with coefficient $1$).
However, for the coefficient of $x$, you need to note that $y'(1.5)=4$ so if $y=x^2+bx+c$ then $y'=2x+b$, so $y'(1.5)=2\times 1.5+b=4\implies b=1$.
Thus, we have that $y=x^2+x+c$ and by comparing sequences, we see $c=0$.

Sequences are not generally thought of in these terms of raw calculus, which studies continuous change over $\mathbb{R}$ rather than discrete changes over $\mathbb{N}$. Instead, we might study recurrence relations.
A method often used for identifying quadratics would be to just find the $x^2$ coefficient by halving the difference of differences (here, $2$) and then subtract that off the original sequence to see what you're left with: $2,6,12,20,30,\dots-1,4,9,16,25,\dots=1,2,3,4,5,\dots$. In general, you know this sequence will be linear; here, you can just see outright it is the identity sequence $x$, so the full sequence is $x^2+x$.
In this case, as a commenter said, you could possibly spot the solution outright: if you notice the numbers are all times tables values you might see $56=7\times 8,42=6\times 7,30=5\times 6$ and conclude $y=x\times (x+1)$.
A: Let $\{a_n\}_{n\in\mathbb N}=\{2,6,12,20,30,42,56,\ldots\}$. Let $\{b_n\}_{n\in\mathbb N}$ be the sequence of the first-order forward differences of $\{a_n\}$, and $\{c_n\}_{n\in\mathbb N}$ the sequence of second-order differences. So for $n\ge1$,
$$b_n = a_{n+1} - a_n \\ c_n = b_{n+1} - b_n$$
As you observed, $c_n=2$ for all $n$. Then
$$\begin{align*}b_{n+1} &= b_n + 2 \\
&= b_{n-1}+2\times2 \\
&= b_{n-2}+3\times2 \\
&~~\vdots \\
&= b_1 + 2n
\end{align*}$$
which means $b_n = b_1+2(n-1)=2(n+1)$.
Now solve for $a_n$:
$$\begin{align*}
a_{n+1} &= a_n + 2(n+1) \\
&= a_{n-1} + 2((n+1) + n) \\
&= a_{n-2} + 2((n+1) + n + (n-1)) \\
&~~\vdots \\
&= a_1 + 2 \sum_{k=0}^{n-1} (n+1-k)\\
&= a_1 + n^2 + 3n
\end{align*}$$
so that $a_n = 2 + (n-1)^2 + 3(n-1) = n^2 + n$.
In case you are interested in the generating function, it takes the form
$$f(x) = \sum_{n=0}^\infty a_n x^n$$
Recall that if $|x|<1$, we have
$$\frac1{1-x} = \sum_{n=0}^\infty x^n$$
and finding $f(x)$ is just a matter of differentiating both sides twice.
$$\frac1{(1-x)^2} = \sum_{n=0}^\infty nx^{n-1} = \sum_{n=1}^\infty nx^{n-1} = \sum_{n=0}^\infty (n+1)x^n$$
$$\frac2{1-x^3} = \sum_{n=0}^\infty (n^2+n) x^{n-1}$$
$$\implies f(x) = \frac{2x}{1-x^3} = \sum_{n=0}^\infty (n^2+n) x^n$$
