Relation between differential equations and sequence recursions

There is indeed a deep connection between the two equations, that is the starting point for the theory of generating functions.

The connection is given by the following one-on-one correspondence between real-valued sequences and powerseries $$i \colon \mathbb R^{\mathbb N} \longrightarrow \mathbb R[[x]]$$ $$i((a_n)_n) = \sum_{n \in \mathbb N} \frac{a_n}{n!}x^n$$ which is an isomorphism between these $\mathbb R$-vector spaces.

By using this isomorphism backward you can endow the space of sequences with a product, defined as $(a_n)_n \cdot (b_n)_n=(\sum_{k=0}^n a_k b_{n-k})_n$, and a derivation operator, which coincides with the shifting operator: $\frac{d}{dx}((a_n)_n)=(a_{n+1})_n$ (it is an easy count to verify that $i\left(\frac{d}{dx}(a_n)_n\right)=\frac{d}{dx}i(a_n)_n$).

You can think of a recursive equation as a sequence of equations, parametrized by the index $n$, that you can fuse into a equation whose terms are expressions build up from sequences using sum, multiplication, scalar multiplication and the shifting/derivator operator.

For instance from recursive equation in your question you can get the following equation $$\frac{d^2}{dx^2}(a_n)_n=5\frac{d}{dx}(a_n)_n -6 (a_n)_n+4(2^nn)_n-2(2^n)_n$$ which through the isomorphism $i$, by letting $y=i(a_n)_n$, becomes $$\frac{d^2}{dx^2}y=5\frac{d}{dx}y-6y+4e^{2x}-2e^{2x}$$ that is the differential equation in you question.

Since these two equations correspond through the isomorphisms $i$ the solutions of the equations correspond one to each other through $i$ too: if $(a_n)_n$ is a solution to the sequence-equation then $i(a_n)_n$ is a solution to the differential equation.

For instance if you take the solution $a_n=6\cdot 3^n-2^n(n^2+2n+5)$ then $$i(a_n)_n = 6e^{3x}-e^{2x}(x^2+2x+5)\ .$$

There could be so much more to say about generating functions but I am afraid that would take us too far from the scope of the question.

I hope this helps.


Yes, you can use the difference operator on a sequence $$ \Delta(a_n) = a_{n+1} - a_n $$ to rewrite the recurrence relations into difference equations, which are a discretized analog of differential equations, with similar method of solution. Just as an example, as $y'=y$ yields an exponential family, $y=Ae^x$, so $\Delta(a_n) = a_n$ yields an exponential family $a_n = A \cdot 2^n$…

For your recurrence relation, the analog would be $$ \Delta^2(a_n) - 4\Delta(a_n) + 2a_n = 2^n(4n-2). $$