 
 
 
 
 
 
Re: difference equation
- To: mathgroup at smc.vnet.net
- Subject: [mg24361] Re: difference equation
- From: Leszek Sczaniecki <lsczan at home.com>
- Date: Sun, 9 Jul 2000 04:53:03 -0400 (EDT)
- Organization: @Home Network
- References: <8k3l8a$3af@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Wilfried Stock wrote:
> Hi
> I would like to built a difference equatition like:
> Yt=A+b*Yt-1-c*Yt-2
> with Y=f(X)
> I don't find an easy solution.
> Can anyone provide a solution?
>
> Thanks in advance,
> Wilfried
In old days this type of equations used to be often solved in the
following way (subtle mathematical details omitted)
     y[n+2] == a + b y[n+1] - c y[n]
     y[1] == y1 , y(0) == y0
There is time for some tricks now. We multiply both sides of the
equation by x^n/n!
     y(n+2) x^n/n! == a x^n/n! + b y(n+1)x^n/n - c y(n)x^n/n
    (d/dx)^2 y[n+2] x^(n+2)/(n+1)! == a x^n/n!
        + b (d/dx)y(n+1)x^(n+1)/(n+1!) - c y(n)x^n/n!
We define a function ( called the generating function)
    f(x) == Sum[y(n) x^(n)/(n+1)!, {n, 0, Infinity}]
The original equation has been transformed to a second order
differential equation with constant coefficients (and known solution
:-))
    (d/dx)^2 f[x] - b (d/dx) f[x] + c f[x] == a Exp[x]
with initial conditions
    ((d/dx) f)[0] == y1  and f[0] == y0 .
y[n] is the n-th derivative of the generating function f with respect to
x taken at x==0.
These days happy owners of Mathematica have another option.
In[1]:= << "DiscreteMath`RSolve`"
In[2]:= sol = RSolve[{y[n + 2] == a + b*y[n + 1] - c*y[n], y[1] == y1,
y[0] == y0}, y[n], n] // FullSimplify
Out[2]= {{y[n] -> 1/(Sqrt[b^2 - 4*c]*(-1 + b - c))*
     2^(-1 - n)*(Sqrt[b^2 - 4*c]*(a*(-2^(1 + n) + (b - Sqrt[b^2 -
4*c])^n +
           (b + Sqrt[b^2 - 4*c])^n) + ((b - Sqrt[b^2 - 4*c])^n + (b +
Sqrt[b^2 - 4*c])^
            n)*(-1 + b - c)*y0) + (b - Sqrt[b^2 - 4*c])^n*(a*(-2 + b) +
         (-1 + b - c)*(b*y0 - 2*y1)) - (b + Sqrt[b^2 - 4*c])^n*
        (a*(-2 + b) + (-1 + b - c)*(b*y0 - 2*y1)))}}
In[4]:= y[n_] = y[n] /. First[sol];
In[5]:= FullSimplify[y[0]]
Out[5]= y0
In[6]:= FullSimplify[y[1]]
Out[6]= y1
It looks like this is a correct solution (at least for 0 <= n <=10).
In[7]:= Table[FullSimplify[y[n + 2] - (a + b*y[n + 1] - c*y[n])], {n, 1,
10}]
Out[7]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Regards,
-- Leszek Sczaniecki

