1 Introduction

First, recall that \({\mathbb{N}}\), \({\mathbb{N}}_{0}\), \({\mathbb{Z}}\), \({\mathbb{R}}\), \({\mathbb{C}}\) stand for natural, nonnegative integer, integer, real and complex numbers, respectively. If \(k_{1},k_{2} \in {\mathbb{Z}}\), \(k_{1}\le k_{2}\), the notation \(j=\overline{k_{1},k _{2}}\) is the same as the following one: \(\{j\in {\mathbb{Z}}: k_{1} \le j\le k_{2}\}\).

Solvability of difference equations is an old area. Many important eighteenth century results can be found in [1,2,3,4,5,6,7], where first serious results of analytic sort on solvability of difference equations were obtained.

First nontrivial difference equation which was solved in closed form was the following:

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

with \(a, b\in {\mathbb{R}}\) [1,2,3].

For some influential nineteenth century presentations of the theory of difference equations, see, for example, [8,9,10]. Books of the twentieth century usually put aside the solvability of the equations and paid more attention to some other topics; nevertheless, they contain quite a lot information on solvability (see, for example, [11,12,13,14,15,16,17,18]). For some interesting historical details and comments, see our recent paper [19].

Use of computers, among other things, enhanced some interest in solvable difference equations, as well as in systems of difference equations. However, a sheer use of them without use of any serious mathematical theory causes some problems (some of the problems were explained, for example, in [20,21,22,23,24]). Knowing explicit formulas for solutions to difference equations and systems has a great applicable potential (see, for example, [11,12,13,14, 25,26,27,28,29,30,31,32,33,34,35] and the related references therein).

Many recent papers on solvability of difference equations and systems use various changes of variables which transform them to well-known solvable ones, usually linear, which are the basic classes of practically or theoretically solvable difference equations. For example, in [20, 21, 36,37,38,39,40] some changes of variables, which in a way can be characterized as standard, were used, whereas some more complex changes of variables, as well as more complex methods, can be found, for example, in [41,42,43,44,45] where some product-type systems of difference equations were considered (see also the related references therein).

One of the most frequent linear difference equations appearing in solvability is the linear first-order one, that is,

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

where \((a_{n})_{n\in {\mathbb{N}}_{0}}\), \((b_{n})_{n\in {\mathbb{N}} _{0}}\), and \(x_{-1}\) are real or complex. Some methods for solving equation (1) can be found, for example, in [11, 12, 15, 16]. Our investigations so far show that equation (1) essentially occupies the central position in the theory of solvability of difference equations.

A closely related topic to the solvability of difference equations and systems is finding invariants for the equations and systems, which is not so popular as the former one. Nevertheless, the topic is no doubt useful in studying of the equations and is also interesting.

For a function \(I:{\mathbb{R}}^{l}\ (\text{or } {\mathbb{C}}^{l}) \to {\mathbb{R}}\ (\text{or } {\mathbb{C}})\), it is said that it is an invariant for a difference equation if

$$\begin{aligned} I(x_{n},x_{n+1},\ldots ,x_{n+l-1})=c, \end{aligned}$$
(2)

for some constant c and every solution to the equation, on its domain.

Invariants are usually used in establishing some properties of solutions to an equation. Frequently they are useful in establishing the boundedness of solutions to a difference equation or a system of difference equations. Many interesting results on the topic can be found in the following papers by Papaschinopoulos and Schinas: [46,47,48,49,50,51] (see also the references therein). However, in some cases they can lead to finding solutions to some difference equations. Some basic examples of such equations will be given in the next section.

In [52] the following nonlinear second-order difference equation has been recently investigated:

$$\begin{aligned} x_{n+1}=x_{n}+\frac{x_{n}}{x_{n}-x_{n-1}} \end{aligned}$$
(3)

for \(n\in {\mathbb{N}}_{0}\), where by a simple inductive argument some formulas for solutions to the difference equation are verified. However, no theory or explanations how the formulas are obtained appear there.

Our main aim is to explain formulas obtained in [52]. We will also extend them for the case of the following equation:

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

where \(d, x_{-1}, x_{0}\in {\mathbb{C}}\). This will be done in a bit unexpected way, by using an invariant of equation (4).

For a solution \((x_{n})\) to a difference equation, we say that it is well-defined if it has defined finite value for each n which belongs to the domain of the difference equation.

2 An example of using invariants and a hint how to use them

Before we present a proof of our main result, in this section we present, as a motivation and for benefit of the reader, an application of the method of invariants on a very basic example of linear first-order difference equation with constant coefficients explaining a frequently confusing detail. We also give a general hint how to use the method of invariants for the case of difference equations of any order.

2.1 Linear first-order difference equation with constant coefficients

Here we consider difference equation (1) when the sequences \((a_{n})_{n\in {\mathbb{N}}_{0}}\) and \((b_{n})_{n\in {\mathbb{N}}_{0}}\) are constant, that is, the linear first-order difference equation with constant coefficients

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

where \(a, b, x_{-1}\in {\mathbb{C}}\), \(a\ne 0\).

Besides the three standard methods for solving difference equation (1) which correspond to the three methods for solving the linear first-order differential equation (see, e.g., [16]), the special choice of sequences \((a_{n})_{n\in {\mathbb{N}}_{0}}\) and \((b_{n})_{n \in {\mathbb{N}}_{0}}\) enables finding general solution to the equation also in some other ways. One of the ways is by use of an invariant. General solution to difference equation (5) in the nontrivial case when \(a\ne 1\) (formula (16)) was found for the first time by Lagrange in [5] (see also [53]).

Now we demonstrate how the method of invariants can be used for solving equation (5) in very detail, which will help to understand the method better. The method is essentially known, but usually scientist are not aware that they use an invariant and do not pay attention to some details.

Let

$$\begin{aligned} I_{1}(x_{n-1},x_{n}):=x_{n}-ax_{n-1} \end{aligned}$$
(6)

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

Since the following obviously holds

$$\begin{aligned} I_{1}(x_{n-1},x_{n})=b, \quad n\in { \mathbb{N}}_{0}, \end{aligned}$$
(7)

(6) is an invariant for equation (5).

An obvious consequence of relation (7) is

$$\begin{aligned} I_{1}(x_{n},x_{n+1})=I_{1}(x_{n-1},x_{n}) \end{aligned}$$
(8)

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

Now note that (8) can be written in the following form:

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

which is a homogeneous linear second-order difference equation with constant coefficients, so solvable.

Since in the case \(a=1\) equation (5) is easily solved, from now on we will assume that \(a\ne 1\).

The characteristic polynomial associated with equation (9) is

$$ p_{2}(\lambda )=\lambda ^{2}-(a+1)\lambda +a, $$

from which it follows that

$$ \lambda _{1}=1 \quad\text{and} \quad \lambda _{2}=a $$

are the characteristic zeros.

Hence, general solution to equation (9) is

$$\begin{aligned} x_{n}=c_{1}+c_{2}a^{n}, \quad n\ge -1, \end{aligned}$$
(10)

where \(c_{1}\) and \(c_{2}\) are arbitrary constants.

To find \(c_{1}\) and \(c_{2}\), it is necessary to solve the linear system

$$\begin{aligned} &c_{1}+\frac{c_{2}}{a}=x_{-1}, \end{aligned}$$
(11)
$$\begin{aligned} &c_{1}+c_{2}=x_{0}, \end{aligned}$$
(12)

from which it follows that

$$\begin{aligned} c_{1}=\frac{ax_{-1}-x_{0}}{a-1} \quad \text{and}\quad c_{2}=a \frac{x _{0}-x_{-1}}{a-1}. \end{aligned}$$
(13)

Using (13) in (10), we have

$$\begin{aligned} x_{n}=\frac{ax_{-1}-x_{0}+(x_{0}-x_{-1})a^{n+1}}{a-1}, \end{aligned}$$
(14)

which is general solution to equation (9) in terms of parameter a and the initial values \(x_{-1}\) and \(x_{0}\).

Now note that from (5) we have

$$\begin{aligned} x_{0}=ax_{-1}+b. \end{aligned}$$
(15)

By using (15) in (14), we obtain

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

The above procedure, although very simple, has many steps. So, at first sight, it is not quite clear what formula (16) represents, although it is expected that it is general solution to difference equation (5), which is easily verified by a simple inductive argument.

The confusion is found in the fact that a relation of the form (8) is a consequence of any relation of the form (7). However, from (8), in general, we cannot conclude that relation of the form (7) holds. Namely, from (8) we have

$$\begin{aligned} I_{1}(x_{n-1},x_{n})=I_{1}(x_{-1},x_{0}) \end{aligned}$$
(17)

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

However, the catch is that in this case \(I_{1}(x_{-1},x_{0})\) is not only equal to b, but the value of \(x_{0}\) is not arbitrary (it is specified, see relation (15)).

So, the above procedure is not one-directional, but, in fact, all the steps are equivalent. More precisely, the initial value problem consisting of equation (5) and initial value \(x_{-1}\) is equivalent to the initial value problem consisting of equation (9) and initial values \(x_{-1}\) and the one given in (15).

Remark 1

The above detailed analysis shows that during applications of the method of invariants for difference equations and systems, it should be tried to transfer a problem to equivalent one, if possible, or, at least, as long as it is possible. Nevertheless, it is suggested that the final formulas are always checked by the method of induction for the case (if a difference equation is complicated, its general solution can be very complicated as it was the case in several recent papers of ours [20, 40, 41, 43, 44]; we have also found several papers with wrong formulas for general solutions to difference equations; see, for example, our comment in [54]).

Remark 2

Obvious consequence of relation (7) appearing in (8) is usually used for the corresponding invariants for difference equations of any order. Namely, if (2) holds, then the following relation

$$\begin{aligned} I(x_{n},x_{n+1},\ldots ,x_{n+l-1})=I(x_{n-1},x_{n}, \ldots ,x_{n+l-2}) \end{aligned}$$
(18)

also holds on the domain of the corresponding difference equation, where l is a fixed natural number.

Of course, if we know invariants for a difference equation or for a system of difference equations, then compositions of the invariants with any other function are also invariants, but the catch is to choose the operative ones, that is, the ones from which we can conclude something on solutions of the difference equation, which in our case refers to finding a closed-form formula for general solution to the difference equation or system.

Remark 3

The above argument can be used to any linear difference equation of the following form

$$\begin{aligned} x_{n}=a_{k}x_{n-1}+\cdots +a_{1}x_{n-k}+b, \quad n\in {\mathbb{N}}_{0}, \end{aligned}$$
(19)

where coefficients \(a_{j}\), \(j=\overline{1,k}\), and b are complex numbers such that \(a_{1}\ne 0\), that is, to nonhomogeneous linear difference equations with constant coefficients whose nonhomogeneous part is constant.

Namely, let

$$\begin{aligned} I_{2}(x_{n-k},x_{n-k+1},\ldots ,x_{n})=x_{n}-a_{k}x_{n-1}- \cdots -a _{1}x_{n-k} \end{aligned}$$
(20)

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

Since it obviously holds

$$\begin{aligned} I_{2}(x_{n-k},x_{n-k+1},\ldots ,x_{n})=b, \quad n\in {\mathbb{N}}_{0}, \end{aligned}$$
(21)

(20) is an invariant for equation (19).

An obvious consequence of relation (21) is

$$\begin{aligned} I_{2}(x_{n-k},x_{n-k+1},\ldots ,x_{n})=I_{2}(x_{n-k+1},x_{n-k+2}, \ldots ,x_{n+1}) \end{aligned}$$
(22)

for \(n\in {\mathbb{N}}_{0}\), which can be written in the following form:

$$\begin{aligned} x_{n+1}-(a_{k}+1)x_{n}-(a_{k-1}-a_{k})x_{n-1}- \cdots -(a_{1}-a_{2})x _{n-k+1}+a_{1}x_{n}=0 \end{aligned}$$
(23)

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

Now note that difference equation (23) is homogeneous linear with constant coefficients, but of order \(k+1\), which is solvable, at least theoretically (equations of order five and more need not be practically solvable due to the Abel–Ruffini theorem which says that polynomials of order five or more need not be solvable by radicals [55]).

Remark 4

Let us also note that there is a custom to show solvability of linear second-order difference equation with constant coefficients prior to showing the solvability of equation (5). It is also interesting to note that de Moivre essentially knew to solve equation (9) already at the beginning of the eighteenth century, but the solvability of equation (5) was discovered several decades later by Lagrange.

3 Main result

Here we show that general solution to difference equation (4) can be found by using the method of invariants, which, at first sight, is a bit unexpected result. The real background for the fact has not been thoroughly investigated yet, but let us say that the idea of getting solution in this way essentially stems from the fact that some difference equations containing quadratic terms have invariants of the form in (20) for fixed \(k\in {\mathbb{N}}\).

Before we start with our analysis of solvability of equation (4) by using the method of invariants, note that if \((x_{n})_{n\ge -1}\) is an arbitrary well-defined solution to the equation, then it must be

$$\begin{aligned} x_{n}-x_{n-1}\ne 0 \end{aligned}$$
(24)

for every \(n\in {\mathbb{N}}_{0}\), since otherwise if, for some \(n_{0}\in {\mathbb{N}}_{0}\), relation (24) does not hold, then the term \(x_{n_{0}+1}\) is not defined.

Note also that if \(d=0\), then equation (4) is reduced to the following difference equation:

$$\begin{aligned} x_{n+1}=x_{n}\frac{x_{n}-x_{n-1}}{x_{n}-x_{n-1}} \end{aligned}$$
(25)

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

From (25) it follows that, if \(x_{0}\ne x_{-1}\), then \(x_{1}=x_{0}\), from which we have that \(x_{2}\) is not defined. This implies that none solution to equation (25) is well-defined.

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

3.1 Solving equation (4) by using an invariant

Equation (4) can be written in the following form:

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

from which it follows that for every well-defined solution \((x_{n})_{n \ge -1}\) to equation (4) we have

$$\begin{aligned} (x_{n+1}-x_{n}) (x_{n}-x_{n-1})=dx_{n} \end{aligned}$$
(27)

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

At this point it should be noted that equations (26) and (27) are not equivalent, since, for example, \(x_{n}=0\), \(n\ge -1\), is a solution to equation (27), while it is not a solution to equation (26).

Let

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

Then from (27) we see that

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

that is, it is an invariant for equation (4).

Now we use the idea which is explained in detail in the previous section (see also Remark 2).

Namely, from (29), we have

$$\begin{aligned} I(x_{n-1},x_{n},x_{n+1})=I(x_{n-2},x_{n-1},x_{n}), \quad n\in {\mathbb{N}}, \end{aligned}$$
(30)

that is,

$$\begin{aligned} (x_{n+1}-x_{n}) (x_{n}-x_{n-1})-dx_{n}=(x_{n}-x_{n-1}) (x_{n-1}-x_{n-2})-dx _{n-1} \end{aligned}$$
(31)

for every \(n\in {\mathbb{N}}\).

From (31) it easily follows that

$$\begin{aligned} (x_{n}-x_{n-1}) (x_{n+1}-x_{n}-x_{n-1}+x_{n-2}-d) \end{aligned}$$
(32)

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

From (24) and (32), it follows that every well-defined solution to equation (4) satisfies the following difference equation:

$$\begin{aligned} x_{n+1}-x_{n}-x_{n-1}+x_{n-2}=d \end{aligned}$$
(33)

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

The characteristic polynomial associated with equation (33) is

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

from which it follows that the characteristic roots are

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

Hence, the general solution to the corresponding linear homogeneous difference equation

$$ x_{n+1}-x_{n}-x_{n-1}+x_{n-2}=0 $$

is given by

$$\begin{aligned} x_{n}^{h}=c_{1}n+c_{2}+c_{3}(-1)^{n} \end{aligned}$$
(36)

for \(n\ge -1\).

Bearing in mind that 1 is a double zero of the characteristic polynomial (34), a particular solution to equation (33) is searched for in the following form:

$$\begin{aligned} x_{n}^{p}=cn^{2} \end{aligned}$$
(37)

for \(n\ge -1\).

Substituting (37) in equation (33) we have that it must be

$$ c\bigl((n+1)^{2}-n^{2}-(n-1)^{2}+(n-2)^{2} \bigr)=d, $$

so that

$$\begin{aligned} c=\frac{d}{4}. \end{aligned}$$
(38)

From (37) and (38) it follows that

$$\begin{aligned} x_{n}^{p}=\frac{d}{4}n^{2} \end{aligned}$$
(39)

for \(n\ge -1\).

From (36), (39) and by a well-known theorem on the structure of solutions to nonhomogeneous linear difference equations (see, e.g., [12, 14,15,16]), we have that the general solution to equation (33) is given by

$$\begin{aligned} x_{n}=c_{1}n+c_{2}+c_{3}(-1)^{n}+ \frac{d}{4}n^{2} \end{aligned}$$
(40)

for \(n\ge -1\).

Now we find constants \(c_{1}\), \(c_{2}\), and \(c_{3}\) in terms of the initial values \(x_{-1}\) and \(x_{0}\). Before this, note that from (4) with \(n=0\) it follows that

$$\begin{aligned} x_{1}=x_{0}\frac{x_{0}-x_{-1}+d}{x_{0}-x_{-1}}. \end{aligned}$$
(41)

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

$$\begin{aligned} &{-} c_{1}+c_{2}-c_{3}=x_{-1}- \frac{d}{4}, \\ & c_{2}+c_{3}=x_{0}, \\ &c_{1}+c_{2}-c_{3}=x_{1}- \frac{d}{4}. \end{aligned}$$
(42)

By adding the first and third equation of system (42) and dividing such obtained equality by 2, we get

$$\begin{aligned} c_{2}-c_{3}=\frac{x_{-1}+x_{1}}{2}-\frac{d}{4}. \end{aligned}$$
(43)

From the second equation in (42) and (43), we similarly get

$$\begin{aligned} &c_{2} =\frac{1}{2} \biggl(x_{0}+\frac{x_{-1}+x_{1}}{2}- \frac{d}{4} \biggr), \end{aligned}$$
(44)
$$\begin{aligned} &c_{3} =\frac{1}{2} \biggl(x_{0}-\frac{x_{-1}+x_{1}}{2}+ \frac{d}{4} \biggr), \end{aligned}$$
(45)

whereas from the first equation in (42) and (43), we obtain

$$\begin{aligned} c_{1}=\frac{x_{-1}+x_{1}}{2}-\frac{d}{4}-x_{-1}+ \frac{d}{4}=\frac{x _{1}-x_{-1}}{2}. \end{aligned}$$
(46)

Using (44)–(46) in (40), we have

$$\begin{aligned} x_{n}=\frac{x_{1}-x_{-1}}{2}n+\frac{4x_{0}+2x_{-1}+2x_{1}-d}{8}+\frac{4x _{0}-2x_{-1}-2x_{1}+d}{8}(-1)^{n}+ \frac{d}{4}n^{2} \end{aligned}$$
(47)

for \(n\ge -1\).

Finally, using (41) in (47), after some calculation we obtain

$$\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) \\ &{}+ \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}$$
(48)

for \(n\ge -1\).

The sequence defined in (48) is a candidate for general solution to equation (4). However, since relations (29) and (30), in general, need not be equivalent, and as we have already noticed equations (26) and (27) are not equivalent, we have to check that the sequence is a solution to equation (4).

Let

$$\begin{aligned} \widetilde{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) \\ &{}+ \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}$$
(49)

for \(n\ge -1\).

A simple calculation shows that, for \(n=-1\) and \(n=0\), we have

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

and

$$\begin{aligned} \widetilde{x}_{0}={}& \frac{1}{8} \biggl(6x_{0}+2x_{-1}+ \frac{2\,dx_{0}}{x _{0}-x_{-1}}-d \biggr) \\ &{}+\frac{1}{8} \biggl(2x_{0}-2x_{-1}- \frac{2\,dx_{0}}{x _{0}-x_{-1}}+d \biggr)=x_{0}. \end{aligned}$$
(51)

From (49) we have

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

and

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

for \(n\ge -1\).

Using (52) and (53), we have

$$\begin{aligned} &\widetilde{x}_{2n} \biggl(1+\frac{d}{\widetilde{x}_{2n}-\widetilde{x} _{2n-1}} \biggr) \\ &\quad = \biggl(x_{0}+n \biggl(x_{0}-x_{-1}+ \frac{dx_{0}}{x_{0}-x_{-1}} \biggr)+dn ^{2} \biggr) \biggl(1+\frac{d}{x_{0}-x_{-1}+nd} \biggr) \\ &\quad = (x_{0}-x_{-1}+nd) \biggl(\frac{x_{0}}{x_{0}-x_{-1}}+n \biggr) \biggl(\frac{x _{0}-x_{-1}+(n+1)\,d}{x_{0}-x_{-1}+nd} \biggr) \\ &\quad = \biggl(\frac{x_{0}}{x_{0}-x_{-1}}+n \biggr) \bigl(x_{0}-x_{-1}+(n+1)d \bigr) \\ &\quad= x_{-1}+(n+1) \biggl(x_{0}-x_{-1}+ \frac{dx_{-1}}{x_{0}-x_{-1}} \biggr)+d(n+1)^{2} \\ &\quad = \widetilde{x}_{2n+1}. \end{aligned}$$
(54)

Using (53) and (54), we have

$$\begin{aligned} &\widetilde{x}_{2n+1} \biggl(1+\frac{d}{\widetilde{x}_{2n+1}- \widetilde{x}_{2n}} \biggr) \\ &\quad = \biggl(x_{-1}+(n+1) \biggl(x_{0}-x_{-1}+ \frac{dx_{-1}}{x_{0}-x_{-1}} \biggr)+d(n+1)^{2} \biggr) \biggl(1+ \frac{d}{\frac{dx _{-1}}{x_{0}-x_{-1}}+(n+1)d} \biggr) \\ &\quad = \biggl(\frac{x_{-1}}{x_{0}-x_{-1}}+n+1 \biggr) \bigl(x_{0}-x_{-1}+d(n+1) \bigr) \biggl(\frac{\frac{x_{-1}}{x_{0}-x_{-1}}+n+2}{\frac{x_{-1}}{x_{0}-x _{-1}}+n+1} \biggr) \\ &\quad = \bigl(x_{0}-x_{-1}+d(n+1)\bigr) \biggl( \frac{x_{-1}}{x_{0}-x_{-1}}+n+2 \biggr) \\ &\quad = x_{0}+(n+1) \biggl(x_{0}-x_{-1}+ \frac{dx_{0}}{x_{0}-x_{-1}} \biggr)+d(n+1)^{2} \\ &\quad = \widetilde{x}_{2n+2}. \end{aligned}$$
(55)

From (54) and (55) it follows that the sequence \((\widetilde{x}_{n})_{n\ge -1}\) is a solution to equation (4), which by (50) matches with the solution with initial values \(x_{-1}\) and \(x_{0}\). Hence, formula (48) really presents general solution to equation (4).

From all the above mentioned results it is easy to see that the following result holds.

Theorem 1

Consider difference equation (4). Then the following statements hold.

  1. (a)

    A solution \((x_{n})_{n\ge -1}\) of difference equation (4) is well-defined if and only if \(x_{-1}\ne x_{0}\).

  2. (b)

    If \(d=0\), then none solution to difference equation (4) is well-defined.

  3. (c)

    If \(d\ne 0\), then the general solution to equation (4) 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) \\ &{}+ \biggl(2x_{0}-2x_{-1}-\frac{2\,dx_{0}}{x_{0}-x_{-1}}+d \biggr) \frac{(-1)^{n}}{8}+\frac{d}{4}n^{2}\quad \textit{for }n\ge -1. \end{aligned}$$