1 Introduction

We use the following standard notations \({\mathbb {N}}\), \({\mathbb {N}}_{0}\), \({\mathbb {Z}}\), \({\mathbb {R}}\), \({\mathbb {C}}\), for natural, nonnegative, whole, real and complex numbers, respectively.

Finding closed-form formulas for solutions to difference equations started at the beginning of the eighteenth century by de Moivre, who knew to solve homogeneous linear difference equations with constant coefficients ([1, 2]). He first solved the difference equation

$$\begin{aligned} x_{n+2}=\widetilde{a} x_{n+1}+\widetilde{b} x_{n}, \quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(1)

by showing that under the conditions \(\widetilde{b}\ne 0\) and \(\widetilde{a}^{2}\ne -4\widetilde{b}\), its general solution is given by the following formula:

$$\begin{aligned} x_{n}=\frac{(x_{1}-\lambda _{2} x_{0})\lambda _{1}^{n}+(\lambda _{1}x_{0}-x_{1})\lambda _{2}^{n}}{\lambda _{1}-\lambda _{2}},\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(2)

where \(\lambda _{1}\) and \(\lambda _{2}\) are roots of the polynomial \(P_{2}(\lambda )=\lambda ^{2}-\widetilde{a}\lambda -\widetilde{b}\). Equation (2) is called the de Moivre formula, whereas the polynomial \(P_{2}\) is called the characteristic polynomial associated to the linear equation (1).

Methods and ideas by de Moivre were later developed by Euler ([3]). The study was continued by Lagrange (see, e.g., [4, 5]), Laplace (see, e.g., [6]), and many other scientists. Several methods for solving some classes of nonlinear difference equations in closed form had been known to Laplace yet ([6]).

From [6] we also see that Laplace essentially knew to solve the class of bilinear difference equations, that is, the following one:

$$\begin{aligned} x_{n+1}=\frac{\alpha x_{n}+\beta }{\gamma x_{n}+\delta },\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(3)

where α, β, γ, δ are given numbers. Let us mention that it is usually assumed that \(\alpha \delta -\beta \gamma \ne 0\ne \gamma \) to avoid dealing with the trivial and linear equations obtained from Eq. (3) (the equation with \(\gamma =0\) was solved by Lagrange in [4]; moreover, the first-order linear difference equation with nonconstant coefficients was also solved therein). For more historical details on some classical difference equations including bilinear one, see [7]. Hence, Eq. (3) is regarded as one of the basic solvable nonlinear difference equations, and can be found in many books ([8,9,10,11,12,13,14]; see also [15]). The equation frequently appears in papers on the solvability of difference equations (see, e.g., the recent papers [7, 16,17,18,19]).

Note that, by using the change of variables

$$ \widetilde{x}_{n}=\gamma x_{n}+\delta ,\quad n\in {\mathbb {N}}_{0}, $$

Equation (3) is transformed to the following one

$$\begin{aligned} \widetilde{x}_{n+1}=\widetilde{\alpha }+\frac{\widetilde{\beta }}{ \widetilde{x}_{n}},\quad n\in {\mathbb {N}}_{0}. \end{aligned}$$
(4)

By using the following change of variables

$$ \widetilde{x}_{n}=\frac{u_{n}}{u_{n-1}},\quad n\in {\mathbb {N}}_{0}, $$

from Eq. (4) we get

$$ u_{n+1}=\widetilde{\alpha }u_{n}+\widetilde{\beta }u_{n-1}, \quad n\in {\mathbb {N}}_{0}, $$

which is an equation of the form in (1), so, solvable one, implying the solvability of Eq. (3) (see, e.g., also [13, 15, 16]).

Nowadays, a part of the scientific community seems uses only computers and symbolic algebra for getting some results on solvability of various equations, including difference ones. This causes several problems, including some on originality of such obtained results. In some of our papers, among other things, we have discussed such problems (see, e.g., [7, 16,17,18,19,20,21,22]). Many of the known solvable difference equations and systems can be transformed to linear ones, which are solvable (for solvability of linear difference equations see, e.g., [8, 9, 14]). This motivated some authors to apply and develop the method of transformation/substitution (see, e.g., [20,21,22,23,24,25,26,27,28,29]). Many applications of solvable difference equations, can be found in the literature which shows their importance (see, e.g., [2, 5, 6, 9,10,11,12,13,14, 30,31,32,33,34,35,36]). For some related results see also [37,38,39,40,41,42].

Now we give a formal definition of solvability of a difference equation.

Definition 1

We say that a difference equation is solvable in closed form if there is a finite number of closed-form formulas from which any well-defined solution to the equation can be obtained.

Some closed-form formulas for solutions to the difference equation

$$\begin{aligned} x_{n+1}=x_{n}+\frac{x_{n}}{x_{n}-x_{n-1}},\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(5)

appeared in [43], where they were proved by induction. However, there was said nothing about the way for obtaining the formulas, which motivated us to find theoretical explanations for getting them. Some explanations, including a method for getting the formulas, have been given, recently, in [44]. This was done in a quite unexpected way. Namely, by using an invariant for Eq. (5). The following solvability result holds ([43, 44]).

Theorem 1

Consider the difference equation

$$\begin{aligned} x_{n+1}=x_{n}+\frac{dx_{n}}{x_{n}-x_{n-1}},\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(6)

where \(d\in {\mathbb {C}}\setminus \{0\}\), and \(x_{-1}, x_{0}\in {\mathbb {C}}\). Then the general solution to Eq. (6) is given by the following formula:

$$\begin{aligned} x_{n}&= \biggl(x_{0}-x_{-1}+\frac{dx_{0}}{x_{0}-x_{-1}} \biggr) \frac{n}{2}+\frac{1}{8} \biggl(6x_{0}+2x_{-1}+ \frac{2\,dx_{0}}{x_{0}-x _{-1}}-d \biggr) \\ &\quad {}+ \biggl(2x_{0}-2x_{-1}-\frac{2\,dx_{0}}{x_{0}-x_{-1}}+d \biggr) \frac{(-1)^{n}}{8}+\frac{d}{4}n^{2}, \end{aligned}$$
(7)

for \(n\ge -1\).

Invariants for difference equations can be useful in their investigations. But it is usually difficult to find those which can be of any use. Invariants for several classes of difference equations and systems of difference equations can be found, e.g., in [45,46,47,48,49,50] (see also the related references therein). They can be useful in finding general solutions to some classes of difference equations, although it is not quite a common situation. Some examples of difference equations which are solved by using invariants can be found in [44, 51] and [52].

Now we define notion of being an invariant for a difference equation.

Definition 2

If for every solution \((x_{n})_{n\ge -k}\) to the difference equation

$$\begin{aligned} x_{n+s}=f(x_{n+s-1},x_{n+s-2},\ldots ,x_{n}), \quad n\ge -k, \end{aligned}$$
(8)

where \(s, k\in {\mathbb {N}}\), there is a function \(I:{\mathbb {R}}^{l}\mbox{ }(\text{or } {\mathbb {C}}^{l})\to {\mathbb {R}}\mbox{ } (\text{or } {\mathbb {C}})\) and a constant c, such that

$$ I(x_{n},x_{n+1},\ldots ,x_{n+l-1})=c,\quad \text{for } n\ge -k, $$

then we say that I is an invariant for Eq. (8).

Motivated by [44] here we study an extension of Eq. (6). Namely, we show that the following generalization of Eq. (6)

$$\begin{aligned} x_{n+1}=ax_{n}+\frac{dx_{n}}{x_{n}-ax_{n-1}},\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(9)

where parameters a and d, and initial values \(x_{-1}\) and \(x_{0}\) are given numbers, can also be solved in closed form, extending and complementing the main result in [44].

We prove this by using two methods. First, this is proved by using an invariant for the difference equation. Since in this way is obtained a closed-form formula for general solution to the equation, this suggests that it might be some other, more standard, methods for getting the formula. Bearing in mind some of our previous investigations on solvability of difference equations and systems of difference equations (see, e.g., [20,21,22, 24,25,26,27,28,29] and number of related references therein), the first natural choice is the method of substitution. Employing some suitably chosen changes of variables we also show the solvability of Eq. (9), confirming the guess.

2 Main results

Our main results are stated and proved in this section. As we have already mentioned, here we present two methods for solving difference equation (9). The first one essentially uses an invariant for the equation together with a nice trick, while the second one is based on the method of substitution where a chain of substitutions is used to get general solution to the equation.

First note that if \(d=0\), then Eq. (9) becomes

$$ x_{n+1}=ax_{n},\quad n\in {\mathbb {N}}_{0}, $$

from which it easily follows that

$$ x_{n}=a^{n}x_{0},\quad n\in {\mathbb {N}}_{0}. $$

Hence, from now on we will assume that \(d\ne 0\).

Also note that if \(a=0\), then Eq. (9) becomes

$$ x_{n+1}=x_{n}\frac{d}{x_{n}},\quad n\in {\mathbb {N}}_{0}, $$

from which it easily follows that every solution to the equation is well-defined if and only if \(x_{0}\ne 0\), and if \(x_{0}\ne 0\), then \(x_{n}=d\), \(n\in {\mathbb {N}}\). Hence, from now on we will also assume that \(a\ne 0\).

Bearing in mind Definition 1, we see also that solutions which are not well-defined should not be taken into the consideration. This means that, for every well-defined solution \((x_{n})_{n\ge -1}\) to the Eq. (9),

$$\begin{aligned} x_{n}\ne ax_{n-1},\quad n\in {\mathbb {N}}_{0}. \end{aligned}$$
(10)

2.1 Solving Eq. (9) by using an invariant

Here we use our idea in [44]. First, note that, from (9), we have

$$\begin{aligned} (x_{n+1}-ax_{n}) (x_{n}-ax_{n-1})-dx_{n}=0, \quad n\in {\mathbb {N}}_{0}. \end{aligned}$$
(11)

Let

$$\begin{aligned} I(u, v, w)=(w-av) (v-au)-dv. \end{aligned}$$
(12)

Then from (11) we see that function (12) is an invariant for Eq. (9).

Now note that

$$ I(x_{n-1}, x_{n}, x_{n+1})=aI(x_{n-2}, x_{n-1}, x_{n}),\quad n\in {\mathbb {N}}, $$

that is,

$$ (x_{n+1}-ax_{n}) (x_{n}-ax_{n-1})-dx_{n}=a(x_{n}-ax_{n-1}) (x_{n-1}-ax _{n-2})-a\,dx_{n-1}, $$

for \(n\in {\mathbb {N}}\), from which it follows that

$$\begin{aligned} (x_{n}-ax_{n-1}) \bigl(x_{n+1}-ax_{n}-ax_{n-1}+a^{2}x_{n-2}-d \bigr),\quad n \in {\mathbb {N}}. \end{aligned}$$
(13)

Since (10) must hold, from (13), we obtain

$$\begin{aligned} x_{n+1}-ax_{n}-ax_{n-1}+a^{2}x_{n-2}=d, \quad n\in {\mathbb {N}}. \end{aligned}$$
(14)

The zeros of the characteristic polynomial

$$\begin{aligned} p_{3}(\lambda )=\lambda ^{3}-a\lambda ^{2}-a\lambda +a^{2}=( \lambda -a) \bigl(\lambda ^{2}-a\bigr), \end{aligned}$$
(15)

associated with (14), are

$$\begin{aligned} \lambda _{1}=a,\qquad \lambda _{2}=\sqrt{a},\qquad \lambda _{3}=- \sqrt{a}. \end{aligned}$$
(16)

Case \(a=1\) was considered in [44]. Hence, the case is omitted here, and we assume that \(a\in {\mathbb {C}}\setminus \{1,0\}\). In this case the characteristic roots in (16) are mutually different. Hence, the general solution to the homogeneous equation

$$ x_{n+1}-ax_{n}-ax_{n-1}+a^{2}x_{n-2}=0 $$

is

$$ x_{n}^{h}=c_{1}a^{n}+c_{2}( \sqrt{a})^{n}+c_{3}(-\sqrt{a})^{n}, \quad n\ge -1, $$

whereas a solution to Eq. (14) can be found in the form

$$ x_{n}^{p}=\widetilde{c},\quad n\ge -1, $$

from which it is easily found that

$$ x_{n}^{p}=\frac{d}{(1-a)^{2}},\quad n\ge -1. $$

Hence,

$$\begin{aligned} x_{n}=c_{1}a^{n}+c_{2}( \sqrt{a})^{n}+c_{3}(-\sqrt{a})^{n}+ \frac{d}{(1-a)^{2}},\quad n\ge -1. \end{aligned}$$
(17)

Using (17) for \(n=-1,0,1\), respectively, we get

$$\begin{aligned} &a^{-1}c_{1}+(\sqrt{a})^{-1}c_{2}-( \sqrt{a})^{-1}c_{3}=x_{-1}- \frac{d}{(1-a)^{2}}, \\ &c_{1}+c_{2}+c_{3}=x_{0}- \frac{d}{(1-a)^{2}}, \\ &ac_{1}+\sqrt{a} c_{2}-\sqrt{a} c_{3}=x_{1}- \frac{d}{(1-a)^{2}}. \end{aligned}$$
(18)

The determinant of system (18) is

$$\begin{aligned} \Delta = \begin{vmatrix} a^{-1} & (\sqrt{a})^{-1} & -( \sqrt{a})^{-1} \\ 1 & 1 & 1 \\ a & \sqrt{a} & -\sqrt{a} \end{vmatrix}=\frac{2(a-1)}{\sqrt{a}}. \end{aligned}$$
(19)

Let

$$\begin{aligned} \widetilde{x}_{j}=x_{j}-\frac{d}{(1-a)^{2}},\quad j=-1,0,1. \end{aligned}$$
(20)

By a well-known theorem, using (19) and (20), and after some calculations, we have

$$\begin{aligned}& \begin{aligned}[b] c_{1}&= \frac{1}{\Delta } \begin{vmatrix} \widetilde{x}_{-1} & (\sqrt{a})^{-1} & -(\sqrt{a})^{-1} \\ \widetilde{x}_{0} & 1 & 1 \\ \widetilde{x}_{1} & \sqrt{a} & -\sqrt{a} \end{vmatrix}= \frac{-2\sqrt{a}\widetilde{x}_{-1}+\frac{2}{\sqrt{a}} \widetilde{x}_{1}}{\Delta } \\ &= \frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d}{a-1}}{a-1}, \end{aligned} \end{aligned}$$
(21)
$$\begin{aligned}& \begin{aligned}[b] c_{2}&= \frac{1}{\Delta } \begin{vmatrix} a^{-1} & \widetilde{x}_{-1} & -(\sqrt{a})^{-1} \\ 1 & \widetilde{x}_{0} & 1 \\ a & \widetilde{x}_{1} & -\sqrt{a} \end{vmatrix}=\frac{(\sqrt{a}+a)\widetilde{x}_{-1}+(\sqrt{a}-\frac{1}{ \sqrt{a}})\widetilde{x}_{0}-(\frac{1}{a}+\frac{1}{\sqrt{a}}) \widetilde{x}_{1}}{\Delta } \\ &= \frac{(1+\sqrt{a})(ax_{-1}-x_{0})- \frac{1+\sqrt{a}}{\sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}-\frac{d( \sqrt{a}+1)^{2}}{\sqrt{a}(a-1)}}{2(a-1)}, \end{aligned} \end{aligned}$$
(22)

and

$$\begin{aligned} c_{3}&=\frac{1}{\Delta } \begin{vmatrix} a^{-1} & ( \sqrt{a})^{-1} & \widetilde{x}_{-1} \\ 1 & 1 & \widetilde{x}_{0} \\ a & \sqrt{a} & \widetilde{x}_{1} \end{vmatrix}=\frac{(\sqrt{a}-a)\widetilde{x}_{-1}+(\sqrt{a}-\frac{1}{ \sqrt{a}})\widetilde{x}_{0}+(\frac{1}{a}-\frac{1}{\sqrt{a}}) \widetilde{x}_{1}}{\Delta } \\ &=\frac{(\sqrt{a}-1)(x_{0}-ax_{-1})+ \frac{1-\sqrt{a}}{\sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d( \sqrt{a}-1)^{2}}{\sqrt{a}(a-1)}}{2(a-1)}. \end{aligned}$$
(23)

Using (21)–(23) in (17), we get

$$\begin{aligned} x_{n}&= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d}{a-1}}{a-1} \biggr)a^{n} \\ &\quad{}+ \biggl(\frac{(1+\sqrt{a})(ax_{-1}-x_{0})-\frac{1+\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}-\frac{d(\sqrt{a}+1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (\sqrt{a})^{n} \\ &\quad{}+ \biggl(\frac{(\sqrt{a}-1)(x_{0}-ax_{-1})+\frac{1-\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d(\sqrt{a}-1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (-\sqrt{a})^{n} + \frac{d}{(a-1)^{2}}, \end{aligned}$$
(24)

for \(n\ge -1\).

Now we check that the sequences given by (24) satisfy Eq. (9). Let

$$\begin{aligned} \widehat{x}_{n}&:= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax _{-1}}+\frac{d}{a-1}}{a-1} \biggr)a^{n} \\ &\quad{}+ \biggl(\frac{(1+\sqrt{a})(ax_{-1}-x_{0})-\frac{1+\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}-\frac{d(\sqrt{a}+1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (\sqrt{a})^{n} \\ &\quad{}+ \biggl(\frac{(\sqrt{a}-1)(x_{0}-ax_{-1})+\frac{1-\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d(\sqrt{a}-1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (-\sqrt{a})^{n} + \frac{d}{(a-1)^{2}}, \end{aligned}$$
(25)

for \(n\ge -1\).

By the way of getting (24) it is clear that

$$\begin{aligned} \widehat{x}_{-1}=x_{-1}\quad \text{and}\quad \widehat{x}_{0}=x_{0}. \end{aligned}$$
(26)

From (25) we have

$$\begin{aligned} \widehat{x}_{2n-1}&:= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax _{-1}}+\frac{d}{a-1}}{a-1} \biggr)a^{2n-1} \\ &\quad{}+ \biggl(\frac{(1+\sqrt{a})(ax_{-1}-x_{0})-\frac{1+\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}-\frac{d(\sqrt{a}+1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (\sqrt{a})^{2n-1} \\ &\quad{}- \biggl(\frac{(\sqrt{a}-1)(x_{0}-ax_{-1})+\frac{1-\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d(\sqrt{a}-1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr) (\sqrt{a})^{2n-1} + \frac{d}{(a-1)^{2}} \\ &= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d}{a-1}}{a-1} \biggr)a^{2n-1} \\ &\quad{}- \biggl(ax_{0}-a^{2}x_{-1}+ \frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d(a+1)}{a-1} \biggr)\frac{a^{n-1}}{a-1} + \frac{d}{(a-1)^{2}} \end{aligned}$$
(27)

and

$$\begin{aligned} \widehat{x}_{2n}&:= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax _{-1}}+\frac{d}{a-1}}{a-1} \biggr)a^{2n} \\ &\quad{}+ \biggl(\frac{(1+\sqrt{a})(ax_{-1}-x_{0})-\frac{1+\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}-\frac{d(\sqrt{a}+1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr)a^{n} \\ &\quad{}+ \biggl(\frac{(\sqrt{a}-1)(x_{0}-ax_{-1})+\frac{1-\sqrt{a}}{ \sqrt{a}}\frac{dx_{0}}{x_{0}-ax_{-1}}+\frac{d(\sqrt{a}-1)^{2}}{ \sqrt{a}(a-1)}}{2(a-1)} \biggr)a^{n} +\frac{d}{(a-1)^{2}} \\ &= \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d}{a-1}}{a-1} \biggr)a^{2n} \\ &\quad{}- \biggl(x_{0}-ax_{-1}+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{2d}{a-1} \biggr)\frac{a ^{n}}{a-1} +\frac{d}{(a-1)^{2}}. \end{aligned}$$
(28)

We also have

$$\begin{aligned} \widehat{x}_{2n}= \biggl(\frac{(x_{0}-x_{-1})a^{n+1}-(x_{0}-ax_{-1})}{(x _{0}-ax_{-1})(a-1)^{2}} \biggr) \bigl((a-1)x_{0}+a(1-a)x_{-1}+d\bigr)a^{n}-d ), \end{aligned}$$
(29)

for \(n\ge -1\).

From (27) and (28), we have

$$ \widehat{x}_{2n}-a\widehat{x}_{2n-1}=\frac{((a-1)x_{0}+a(1-a)x_{-1}+d)a ^{n}-d}{a-1}, $$

from which it follows that

$$\begin{aligned} a+\frac{d}{\widehat{x}_{2n}-a\widehat{x}_{2n-1}}&=a+\frac{d(a-1)}{((a-1)x _{0}+a(1-a)x_{-1}+d)a^{n}-d} \\ &=\frac{((a-1)x_{0}+a(1-a)x_{-1}+d)a^{n+1}-d}{((a-1)x_{0}+a(1-a)x _{-1}+d)a^{n}-d}. \end{aligned}$$
(30)

By using (29) and (30), we have

$$\begin{aligned} &\widehat{x}_{2n} \biggl(a+ \frac{d}{\widehat{x}_{2n}-a\widehat{x}_{2n-1}} \biggr) \\ &\quad = \biggl(\frac{(x_{0}-x_{-1})a^{n+1}-(x_{0}-ax_{-1})}{(x_{0}-ax_{-1})(a-1)^{2}} \biggr) \bigl((a-1)x_{0}+a(1-a)x_{-1}+d \bigr)a^{n+1}-d ) \end{aligned}$$
(31)
$$\begin{aligned} &\quad = \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d}{a-1}}{a-1} \biggr)a^{2n+1} \\ &\qquad{}- \biggl(ax_{0}-a^{2}x_{-1}+ \frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d(a+1)}{a-1} \biggr)\frac{a^{n}}{a-1} + \frac{d}{(a-1)^{2}} \end{aligned}$$
(32)
$$\begin{aligned} &\quad =\widehat{x}_{2n+1}. \end{aligned}$$
(33)

From (28) and (32), we have

$$ \widehat{x}_{2n+1}-a\widehat{x}_{2n}=\frac{d((x_{0}-x_{-1})a^{n+1}-(x _{0}-ax_{-1}))}{(x_{0}-ax_{-1})(a-1)}, $$

from which it follows that

$$\begin{aligned} a+\frac{d}{\widehat{x}_{2n+1}-a\widehat{x}_{2n}}&=a+\frac{(x_{0}-ax _{-1})(a-1)}{(x_{0}-x_{-1})a^{n+1}-(x_{0}-ax_{-1})} \\ &=\frac{(x_{0}-x_{-1})a^{n+2}-(x_{0}-ax_{-1})}{(x_{0}-x_{-1})a^{n+1}-(x _{0}-ax_{-1})}. \end{aligned}$$
(34)

Using (31) and (34), we have

$$\begin{aligned} &\widehat{x}_{2n+1} \biggl(a+\frac{d}{\widehat{x}_{2n+1}-a\widehat{x} _{2n}} \biggr) \\ &\quad = \biggl(\frac{((a-1)(x_{0}-ax_{-1})+d)a^{n+1}-d}{(a-1)^{2}(x_{0}-ax _{-1})} \biggr) \bigl((x_{0}-x_{-1})a^{n+2}-(x_{0}-ax_{-1}) \bigr) \\ &\quad = \biggl(\frac{a(x_{0}-x_{-1})+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{d}{a-1}}{a-1} \biggr)a^{2n+2} \\ &\qquad{}- \biggl(x_{0}-ax_{-1}+\frac{dx_{0}}{x_{0}-ax_{-1}}+ \frac{2d}{a-1} \biggr)\frac{a ^{n+1}}{a-1} +\frac{d}{(a-1)^{2}} \\ &\quad =\widehat{x}_{2n+2}. \end{aligned}$$
(35)

Equations (26), (33), (35) together with induction show that (25) is a solution to (9). Hence, we have the following theorem, which complements Theorem 1.

Theorem 2

Consider Eq. (9). If \(a\ne 1\), then the general solution to the equation is given by Eq. (24).

2.2 Solving Eq. (9) by the method of substitution

Before we start describing the procedure for finding general solution to Eq. (9), which is based on the method of substitution (use of some changes of variables), we would like to point out that if

$$\begin{aligned} x_{n_{0}}=0\quad \text{and}\quad x_{n_{0}}\ne ax_{n_{0}-1}, \end{aligned}$$
(36)

for some \(n_{0}\in {\mathbb {N}}_{0}\) (of course, we regard that terms \(x_{n}\) are defined for \(-1\le n\le n_{0}\)), then from (9) it follows that \(x_{n_{0}+1}=0\), from which along with (36) it follows that \(x_{n_{0}+1}-ax_{n_{0}}=0\), implying that \(x_{n_{0}+2}\) is not defined. Hence, such solutions are not well-defined. So, from now on we may also assume that

$$\begin{aligned} x_{n}\ne 0, \end{aligned}$$
(37)

for every \(n\in {\mathbb {N}}_{0}\). Value of \(x_{-1}\) can be equal to zero and it essentially does not effect the final solution. However, since it effects some steps of this procedure for finding general solution, we will also assume that \(x_{-1}\ne 0\).

Our first idea is to write Eq. (9) in the form of a product-type difference equations, which along with systems of product-type difference equations have been considerably studied (see, e.g., [28, 53,54,55] and the related references therein).

So, first note that from (9) we have

$$\begin{aligned} x_{n+1}-ax_{n}=\frac{dx_{n}}{x_{n}-ax_{n-1}},\quad n\in {\mathbb {N}}_{0}. \end{aligned}$$
(38)

Hence

$$\begin{aligned} x_{n}-ax_{n-1}=\frac{dx_{n-1}}{x_{n-1}-ax_{n-2}},\quad n\in {\mathbb {N}}. \end{aligned}$$
(39)

By using (39) in (38), it follows that

$$\begin{aligned} x_{n+1}-ax_{n}=\frac{x_{n}}{x_{n-1}}(x_{n-1}-ax_{n-2}), \quad n\in {\mathbb {N}}. \end{aligned}$$
(40)

Equation (40) can be written in the form

$$\begin{aligned} \frac{x_{n+1}}{x_{n}}=a+1-a\frac{x_{n-2}}{x_{n-1}},\quad n\in {\mathbb {N}}. \end{aligned}$$
(41)

By using the change of variables

$$\begin{aligned} y_{n}=\frac{x_{n}}{x_{n-1}},\quad n\in {\mathbb {N}}_{0}, \end{aligned}$$
(42)

Equation (41) becomes

$$\begin{aligned} y_{n+1}=a+1-\frac{a}{y_{n-1}},\quad n\in {\mathbb {N}}. \end{aligned}$$
(43)

Now note that the difference equation (43) is an equation with interlacing indices of order two ([17, 20]). This means that the sequences

$$\begin{aligned} y_{m}^{(i)}:=y_{2m+i}, \end{aligned}$$
(44)

for \(m\in {\mathbb {N}}_{0}\) and \(i=0,1\), are two solutions to the first-order difference equation

$$\begin{aligned} z_{m+1}=a+1-\frac{a}{z_{m}},\quad m\in {\mathbb {N}}_{0}. \end{aligned}$$
(45)

Equation (45) is a special case of the bilinear difference equation, or more precisely, of Eq. (4). Hence, it is solvable, implying solvability of Eq. (43), which along with the change of variables (42) implies solvability of Eq. (40).

There are two cases to be considered: (1) \(a=1\); (2) \(a\ne 1\).

Case \(a=1\). In this case Eq. (45) becomes

$$\begin{aligned} z_{m+1}=2-\frac{1}{z_{m}},\quad m\in {\mathbb {N}}_{0}. \end{aligned}$$
(46)

By using the change of variables

$$\begin{aligned} z_{m}=\frac{u_{m}}{u_{m-1}},\quad m\in {\mathbb {N}}_{0}, \end{aligned}$$
(47)

where we assume that \(u_{-1}\) is a nonzero number, we get

$$\begin{aligned} u_{m+1}=2u_{m}-u_{m-1},\quad m\in {\mathbb {N}}_{0}. \end{aligned}$$
(48)

Since the roots of the characteristic polynomial \(\widetilde{P}_{2}(\lambda )=\lambda ^{2}-2\lambda +1\) associated with Eq. (48) are \(\lambda _{1}=\lambda _{2}=1\), then the general solution to Eq. (48) is

$$\begin{aligned} u_{m}=\widehat{c}_{1}m+\widehat{c}_{2},\quad m \ge -1, \end{aligned}$$
(49)

from which it follows that

$$\begin{aligned} u_{m}=(u_{0}-u_{-1})m+u_{0}=u_{0}(m+1)-u_{-1}m, \quad m\ge -1. \end{aligned}$$
(50)

By using (50) in (47), we obtain

$$\begin{aligned} z_{m}=\frac{u_{0}(m+1)-u_{-1}m}{u_{0}m-u_{-1}(m-1)}=\frac{z_{0}(m+1)-m}{z _{0}m-m+1},\quad m\in {\mathbb {N}}_{0}. \end{aligned}$$
(51)

From (44) and (51), it follows that

$$ y_{2m+i}=y_{m}^{(i)}=\frac{y_{0}^{(i)}(m+1)-m}{y_{0}^{(i)}m-m+1}= \frac{y _{i}(m+1)-m}{y_{i}m-m+1}, $$

for \(m\in {\mathbb {N}}_{0}\) and \(i=0,1\), that is,

$$\begin{aligned}& y_{2m}=\frac{y_{0}(m+1)-m}{y_{0}m-m+1}=\frac{x_{0}(m+1)-x_{-1}m}{x _{0}m-x_{-1}(m-1)}, \end{aligned}$$
(52)
$$\begin{aligned}& \begin{aligned}[b] y_{2m+1}&=\frac{y_{1}(m+1)-m}{y_{1}m-m+1}=\frac{x_{1}(m+1)-x_{0}m}{x _{1}m-x_{0}(m-1)}= \frac{(x_{0}+\frac{dx_{0}}{x_{0}-x_{-1}})(m+1)-x _{0}m}{(x_{0}+\frac{dx_{0}}{x_{0}-x_{-1}})m-x_{0}(m-1)} \\ &=\frac{d(m+1)+x_{0}-x_{-1}}{dm+x_{0}-x_{-1}},\quad m\in {\mathbb {N}}_{0}. \end{aligned} \end{aligned}$$
(53)

From (42) we have

$$\begin{aligned} x_{n}=x_{-1}\prod_{j=0}^{n}y_{j}, \quad n\ge -1. \end{aligned}$$
(54)

Hence, (52)–(54) yield

$$\begin{aligned} x_{2n-1}&=x_{-1}\prod_{j=0}^{2n-1}y_{j}=x_{-1} \prod_{i=0}^{n-1}y_{2i} \prod _{i=0}^{n-1}y_{2i+1} \\ &=x_{-1}\prod_{i=0}^{n-1} \frac{x_{0}(i+1)-x_{-1}i}{x_{0}i-x_{-1}(i-1)}\prod_{i=0}^{n-1} \frac{d(i+1)+x _{0}-x_{-1}}{di+x_{0}-x_{-1}} \\ &=x_{-1}\frac{x_{0}n-x_{-1}(n-1)}{x_{-1}}\cdot \frac{dn+x_{0}-x_{-1}}{x _{0}-x_{-1}} \\ &=\bigl((x_{0}-x_{-1})n+x_{-1}\bigr) \biggl( \frac{dn}{x_{0}-x_{-1}}+1 \biggr) \end{aligned}$$
(55)
$$\begin{aligned} &=x_{-1}+ \biggl(x_{0}-x_{-1}+\frac{dx_{-1}}{x_{0}-x_{-1}} \biggr)n+dn ^{2}, \end{aligned}$$
(56)

for \(n\in {\mathbb {N}}_{0}\).

Employing (42), (52), (54) and (55), we get

$$\begin{aligned} x_{2n}&=x_{-1}\prod_{j=0}^{2n}y_{j}=x_{2n-1}y_{2n} \\ &=\bigl((x_{0}-x_{-1})n+x_{-1}\bigr) \biggl( \frac{dn}{x_{0}-x_{-1}}+1 \biggr)\frac{x _{0}(n+1)-x_{-1}n}{x_{0}n-x_{-1}(n-1)} \\ &= \biggl(\frac{dn}{x_{0}-x_{-1}}+1 \biggr) \bigl((x_{0}-x_{-1})n+x_{0} \bigr) \\ &=x_{0}+ \biggl(x_{0}-x_{-1}+\frac{dx_{0}}{x_{0}-x_{-1}} \biggr)n+dn ^{2}, \end{aligned}$$
(57)

for \(n\in {\mathbb {N}}_{0}\).

It is easy to see that Eqs. (56) and (57) match with Eq. (7), which shows that the method also leads to finding the general solution to Eq. (9) in this case.

Case \(a\ne 1\). By using the change of variables (47) in Eq. (45) we obtain

$$\begin{aligned} u_{m+1}=(a+1)u_{m}-au_{m-1}, \end{aligned}$$
(58)

for \(m\in {\mathbb {N}}_{0}\).

Since the roots of the characteristic polynomial

$$ \widehat{P}_{2}(\lambda )=\lambda ^{2}-(a+1)\lambda +a $$

associated with homogeneous linear difference equation (58) are \(\lambda _{1}=a\), \(\lambda _{2}=1\), then by using the de Moivre formula (2) it follows that the general solution to Eq. (58) is

$$\begin{aligned} u_{m}=\frac{(u_{0}-u_{-1})a^{m+1}+au_{-1}-u_{0}}{a-1}, \end{aligned}$$
(59)

for \(m\ge -1\).

Employing (59) in (47), we obtain

$$\begin{aligned} z_{m}&=\frac{(u_{0}-u_{-1})a^{m+1}+au_{-1}-u_{0}}{(u_{0}-u_{-1})a^{m}+au _{-1}-u_{0}} \\ &=\frac{(z_{0}-1)a^{m+1}+a-z_{0}}{(z_{0}-1)a^{m}+a-z_{0}}, \end{aligned}$$
(60)

for \(m\in {\mathbb {N}}_{0}\).

From (60), it follows that

$$ y_{2m+i}=y_{m}^{(i)}=\frac{(y_{0}^{(i)}-1)a^{m+1}+a-y_{0}^{(i)}}{(y _{0}^{(i)}-1)a^{m}+a-y_{0}^{(i)}}= \frac{(y_{i}-1)a^{m+1}+a-y_{i}}{(y _{i}-1)a^{m}+a-y_{i}}, $$

for \(m\in {\mathbb {N}}_{0}\) and \(i=0,1\), from which together with (42) we have

$$\begin{aligned}& y_{2m}=\frac{(y_{0}-1)a^{m+1}+a-y_{0}}{(y_{0}-1)a^{m}+a-y_{0}}=\frac{(x _{0}-x_{-1})a^{m+1}+ax_{-1}-x_{0}}{(x_{0}-x_{-1})a^{m}+ax_{-1}-x_{0}}, \end{aligned}$$
(61)
$$\begin{aligned}& \begin{aligned}[b] y_{2m+1}&=\frac{(y_{1}-1)a^{m+1}+a-y_{1}}{(y_{1}-1)a^{m}+a-y_{1}}=\frac{(x _{1}-x_{0})a^{m+1}+ax_{0}-x_{1}}{(x_{1}-x_{0})a^{m}+ax_{0}-x_{1}} \\ &=\frac{((a-1)x_{0}+\frac{dx_{0}}{x_{0}-ax_{-1}})a^{m+1}-\frac{dx _{0}}{x_{0}-ax_{-1}}}{((a-1)x_{0}+\frac{dx_{0}}{x_{0}-ax_{-1}}))a^{m}-\frac{dx _{0}}{x_{0}-ax_{-1}}} \\ &=\frac{((a-1)(x_{0}-ax_{-1})+d)a^{m+1}-d}{((a-1)(x_{0}-ax_{-1})+d)a ^{m}-d}, \end{aligned} \end{aligned}$$
(62)

for \(m\in {\mathbb {N}}_{0}\).

By using (54), (61) and (62), we have

$$\begin{aligned} x_{2n-1}&=x_{-1}\prod_{i=0}^{n-1}y_{2i} \prod_{i=0}^{n-1}y_{2i+1} \\ &=x_{-1}\prod_{i=0}^{n-1} \frac{(x_{0}-x_{-1})a^{i+1}+ax_{-1}-x_{0}}{(x _{0}-x_{-1})a^{i}+ax_{-1}-x_{0}}\prod_{i=0}^{n-1} \frac{((a-1)(x_{0}-ax _{-1})+d)a^{i+1}-d}{((a-1)(x_{0}-ax_{-1})+d)a^{i}-d} \\ &=\frac{ ((x_{0}-x_{-1})a^{n}+ax_{-1}-x_{0} ) (((a-1)(x_{0}-ax _{-1})+d)a^{n}-d )}{(a-1)^{2}(x_{0}-ax_{-1})}, \end{aligned}$$
(63)

for \(n\in {\mathbb {N}}_{0}\).

Further, from (54), (61) and (63), we get

$$\begin{aligned} x_{2n}&=x_{2n-1}y_{2n} \\ &=\frac{ ((x_{0}-x_{-1})a^{n}+ax_{-1}-x_{0} ) (((a-1)(x_{0}-ax _{-1})+d)a^{n}-d )}{(a-1)^{2}(x_{0}-ax_{-1})} \\ &\quad{}\times \frac{(x_{0}-x_{-1})a^{n+1}+ax_{-1}-x_{0}}{(x_{0}-x_{-1})a ^{n}+ax_{-1}-x_{0}} \\ &=\frac{ (((a-1)(x_{0}-ax_{-1})+d)a^{n}-d ) ((x_{0}-x_{-1})a ^{n+1}+ax_{-1}-x_{0} )}{(a-1)^{2}(x_{0}-ax_{-1})}, \end{aligned}$$
(64)

for \(n\in {\mathbb {N}}_{0}\).

It is easy to see that Eqs. (63) and (64) match with Eq. (24) (see also (29) and (31)), which shows that the method of substitution also leads to finding a general solution to Eq. (9) in this case.

Remark 1

Recall that solvability of Eq. (45) obviously implies solvability of Eq. (40). But it is not immediately clear why Eqs. (63) and (64) present a general solution to Eq. (9). To be on the safe side the formulas should be checked by induction. Nevertheless, the question needs an answer. The catch is that we consider here only well-defined solutions, that is, the solutions which satisfy condition (10). This means that for such solutions Eq. (40) is equivalent to the following one:

$$ \frac{(x_{n+1}-ax_{n})(x_{n}-ax_{n-1})}{dx_{n}}=\frac{(x_{n}-ax_{n-1})(x _{n-1}-ax_{n-2})}{dx_{n-1}},\quad n\in {\mathbb {N}}, $$

which is clearly equivalent to the following one:

$$\begin{aligned} \frac{(x_{n+1}-ax_{n})(x_{n}-ax_{n-1})}{dx_{n}}=\frac{(x_{1}-ax_{0})(x _{0}-ax_{-1})}{dx_{0}},\quad n\in {\mathbb {N}}. \end{aligned}$$
(65)

Now note that, from (9) with \(n=0\), we get

$$\begin{aligned} \frac{(x_{1}-ax_{0})(x_{0}-ax_{-1})}{dx_{0}}=1. \end{aligned}$$
(66)

From (65) and (66), we get relation (9).

Hence, a well-defined solution to Eq. (9) satisfy Eqs. (9) and (40) simultaneously.