Given $x_{0}$ and $x_{1}$, is there a formula to find $x_n = d\,(2\,x_{n-1} - x_{n-2})$ at a specified $n$? The question covers the main problem I want to solve: $d$ can be any scalar constant (ideally in between 0 and 1, if that makes the problem easier), as well as $x_{0}$ and $x_{1}$. I tried figuring this out on my own, but if the answer is there it is eluding me (this uses an almost identical sequence, but I have no idea what difference equations are to know if that's relevant). This was inspired after learning about the Hugo Elias algorithm for efficiently generating water ripples, if that helps at all. I would be grateful for any help regarding this problem!
As a side note, I may not know the correct terms for everything, so please feel free to let me know or modify this question with more accurate terminology!
 A: $$x_n = d\,(2\,x_{n-1} - x_{n-2})$$ The chaacteristic equation is
$$r^2= d\,(2\,r - 1)$$ the roots of which being
$$r_1=d-\sqrt{d^2-d} \qquad \text{and} \qquad r_2=d+\sqrt{d^2-d}$$ giving as solution
$$x_n=c_1 \,r_1^n+c_2\,r_2^n$$ Now, applynig the conditions
$$x_0=c_1+c_2\qquad \text{and} \qquad x_1=c_1\, r_1+c_2 \,r_2$$ SOlving the two linear equations
$$c_1=\frac {x_1-x_0\, r_2 } {r_1-r_2 }\qquad \text{and} \qquad c_2=\frac{r_1\, x_0-x_1 }{r_1-r_2 }$$
Just replace $r_1$ and $r_2$ by their expressions (the result, even simple, will not be very nice).
A: Yes, there is a closed form for $x_n$.
Consider the sequence $\mathcal F(a,b,f_0,f_1)=(f_n)_{n\ge0}$ with $$f_{n+2}=af_{n+1}+bf_n\qquad n\ge0,\tag1$$
and $a,b,f_0,f_1$ known constants. Then consider the generating function
$$f(x)=\sum_{n\ge0}f_nx^n.$$
Multiply $(1)$ by $x^{n+2}$ and sum over $n\ge0$:
$$\sum_{n\ge2}f_nx^n=ax\sum_{n\ge1}f_nx^n+bx^2\sum_{n\ge0}f_nx^n,$$
which is
$$f(x)-f_1x-f_0=ax(f(x)-f_0)+bx^2f(x).$$
Solving for $f$, we get
$$f(x)=\frac{(f_1-af_0)x+f_0}{1-ax-bx^2}.$$
Then we can write $$\frac{(f_1-af_0)x+f_0}{1-ax-bx^2}=\frac{u_1}{1-v_1x}+\frac{u_2}{1-v_2x},$$
for the constants $u_i,v_i$ such that
$$\begin{align}
u_1v_2+u_2v_1&=af_0-f_1,\qquad &u_1+u_2&=f_0,\\
v_1+v_2&=a,\qquad &v_1v_2&=-b.
\end{align}$$
This system of equations has the solution
$$\begin{bmatrix} 
v_1 \\
v_2 \\
u_1 \\
u_2 \\
\end{bmatrix}
=
\begin{bmatrix}
\tfrac{a+\sqrt{D}}{2}\\
\tfrac{a-\sqrt{D}}{2}\\
\tfrac{1}{\sqrt{D}}\left(f_1+\tfrac{-a+\sqrt{D}}{2}f_0\right)\\
\tfrac{1}{\sqrt{D}}\left(-f_1+\tfrac{a+\sqrt{D}}{2}f_0\right)
\end{bmatrix},\qquad D=a^2+4b.\tag2$$
We have
$$\sum_{n\ge0}f_nx^n=\frac{(f_1-af_0)x+f_0}{1-ax-bx^2}=\frac{u_1}{1-v_1x}+\frac{u_2}{1-v_2x}=u_1\sum_{n\ge0}(v_1x)^n+u_2\sum_{n\ge0}(v_2x)^n,$$
that is
$$\sum_{n\ge0}f_nx^n=\sum_{n\ge0}(u_1v_1^n+u_2v_2^n)x^n,$$
so that $$f_n=u_1v_1^n+u_2v_2^n.\tag3$$
Since you are given $x_0,x_1$, we have $x_n=f_n\in\mathcal F(2d,-d,x_0,x_1)$.
$$\begin{bmatrix} 
v_1 \\
v_2 \\
u_1 \\
u_2 \\
\end{bmatrix}
=
\begin{bmatrix}
d+\sqrt{d(d-1)}\\
d-\sqrt{d(d-1)}\\
\tfrac{1}{2\sqrt{d(d-1)}}\left(x_1+(-d+\sqrt{d(d-1)})x_0\right)\\
\tfrac{1}{2\sqrt{d(d-1)}}\left(-x_1+(d+\sqrt{d(d-1)})x_0\right)
\end{bmatrix},$$
so that
$$\begin{align}
x_n=\tfrac{1}{2\sqrt{d(d-1)}}\Bigg\{&\left(x_1+\left(-d+\sqrt{d(d-1)}\right)x_0\right)\left(d+\sqrt{d(d-1)}\right)^n\\
&+\left(-x_1+\left(d+\sqrt{d(d-1)}\right)x_0\right)\left(d-\sqrt{d(d-1)}\right)^n\Bigg\}.
\end{align}$$
