Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Difference equations

  1. Aug 19, 2005 #1
    Hi I'm just wondering what difference/recurrence equations are about. From what I can recall from the bits and pieces I've readed, difference equations are somewhat similar or an analogue of differential equations. I've read through some things on first and second order difference equations but I don't really understand what they are about.

    My book introduces difference equations as summations. They seem to be equations involving summations with different indices. I know what I've said is a little vague so here is an example question I have(not from the book I referred to).

    Q. Find the general solution of the following difference equation.

    [tex]y_{n + 1} - y_n = 2[/tex]

    Answer: [tex]y_n = A\left( {\frac{1}{2}} \right)^n + 2[/tex]

    Can someone explain to me what the equation actually means?. Any sort of explanation or references to useful websites would also be good. As I alluded to before I don't actually see the connection between difference equations and differential equations. Is it like when you have a real function f(x) and you the sequence f(n)? Any help would be appreciated.
  2. jcsd
  3. Aug 19, 2005 #2


    User Avatar
    Science Advisor
    Homework Helper

    I have no idea what this could mean. Assuming that solution is correct:

    [tex]y_{n+1} - y_{n} = A\left (\frac 12 \right )^{n+1} + 2 - A\left (\frac 12 \right )^n - 2 = -\frac 12A\left (\frac 12 \right )^n[/tex]


    [tex]2 = -\frac 12A\left (\frac 12 \right )^n[/tex]

    [tex]A = -2^{n+2}[/tex]

    [tex]y_n = -4 + 2 = -2[/tex]
  4. Aug 19, 2005 #3


    User Avatar
    Homework Helper

    The two main ways difference and differential equations are related are
    1. Analogous formula
    2. differential equations can be seen as differential equations where the differences are taken to zero in a limit sense.
    your equation
    perform indefinite summation on both sides


    where y0 is the constant to be found by initial conditions.
    The equation means find the functions with the given difference.

    Last edited: Aug 19, 2005
  5. Aug 19, 2005 #4


    User Avatar
    Science Advisor
    Homework Helper

    What you have is an arithmetic series and your "answer" is incorrect. The correct solution is

    [tex]y_n = y_1 + (n-1)\times 2[/tex]

    where [itex]y_1[/itex] is an initial value. The answer you show looks like the solution of a geometric series. Did you copy the problem correctly?
  6. Aug 20, 2005 #5
    I left out a factor 2 for the first term in the question. It should be [tex]2y_{n + 1} - y_n = 2[/tex] and the answer is the one that I included with my first post.
  7. Aug 20, 2005 #6


    User Avatar
    Science Advisor
    Homework Helper

    In that case, I would subtract [itex]y_n[/itex] from both sides to make it look like a difference equation and see where it leads:

    [tex]2 (y_{n+1} - y_n}) = 2 - y_n[/tex]


    [tex]y_{n+1} - y_n = \frac {2-y_n}{2}[/tex]

    The right side suggests defining a new variable [itex]z_n[/itex] such that [itex]z_n = y_n - 2[/itex] or [itex]y_n = z_n + 2[/tex]. Substitute that into the equation:

    [tex]z_{n+1} + 2 - z_n - 2 = -\frac {1}{2} z_n[/tex]


    [tex]z_{n+1} - z_n = -\frac {1}{2} z_n[/tex]

    Notice the additive constants are now gone! In fact, if we now just add [itex]z_n[/itex] to both side we obtain the simple relation

    [tex]z_{n+1} = \frac {1}{2} z_n[/tex]

    which is just a simple geometric series with the solution

    [tex]z_n = \left( \frac {1}{2} \right)^{n-1} z_1[/tex]

    You should be able to go from there and find the general solution for [itex]y_n[/itex] using the defintion of [itex]z_n[/itex] that we used.
  8. Aug 20, 2005 #7


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    We can do other things, inspired by the methods of differential equations.

    First, some notation:

    [tex]Ey_n := y_{n+1}[/tex]

    Δ = E - 1
    or, equivalently,

    [tex]\Delta y_n := y_{n+1} - y_n[/tex]

    So, you have the equation 2Ey - y = 2. We'd like to rewrite it as Tide suggested. The "easy" way is to recognize you can subtract y from both sides, but if you didn't notice that, you could use E = 1 + Δ to get:

    2 (1 + Δ) y - y = 2
    2y + 2Δy - y = 2
    2Δy + y = 2
    Δy + (1/2) y = 1

    First, the "plug and chug" method: this will be uninspired, but it does give you a solution to any difference equation with summations and products. You can safely skip down to the next section if you like.

    In an ordinary differential equation we look for an integrating factor μ... we can do the same here. Notice that:

    Δ(μy) = Eμ Δy + Δμ y

    So, what we want is (Δμ) / Eμ = (1/2). Using Δ = E - 1, we can rearrange this to form:

    Eμ = 2μ

    By picking an initial value for [itex]\mu_0[/itex], in the general case we can write μ as a product. Here, however, we can find the closed form solution:

    [tex]\mu_n = 2^n[/tex]

    So now, we have:

    Δy + (1/2) y = 1
    Δy + (Δμ)/(Eμ) y = 1
    Eμ Δy + Δμ y = Eμ
    Δ(μy) = Eμ

    And now, we can take an antidifference (i.e. a sum). Notice that:

    \sum_{k = 0}^{n-1} \Delta z_k = z_n - z_0

    We can apply this here to get:

    \mu_n y_n - \mu_0 y_0 &= \sum_{k = 0}^{n-1} E \mu_k \\
    2^n y_n - y_0 &= \sum_{k = 0}^{n - 1} 2^{k+1} \\
    &= 2^{n+1} - 2 \\
    y_n &= 2^{-n} y_0 + 2 - 2^{1-n} \\
    &= A 2^{-n} + 2

    Where the last step was just collecting the coefficients.


    Just like with differential equations, we recognize special forms that come up frequently. Recall that we are trying to solve:

    Δy + (1/2) y = 1

    The homogenous part is Δh + (1/2) h = 0. This has constant coefficients, so we can immediately posit the solution [itex]h_n = r^n[/itex]. Plugging this in gives:

    [tex](r - 1) r^n + (1/2) r^n = 0[/tex]

    Which is easily solved to give r = (1/2). So, the homogenous solution is [itex]h_n = A (1/2)^n[/itex].

    Now to find a particular solution of the original equation. Since the R.H.S. is also a constant, we can immediately posit a constant solution for y. (If the R.H.S. was a polynomial of degree n, we could posit a polynomial of degree n as a solution for y) This is easily seen to be y = 2.

    So, the general solution is:

    [tex]y_n = A (1/2)^n + 2[/tex]
  9. Aug 21, 2005 #8
    Thanks for the help guys but I still don't really understand well enough the main thing which characterises difference equations. I just read my book again and it says that first order recurrence relations for which n = 1 are exemplified by [tex]u_{n + 1} = au_n + k[/tex] with u_0 specified. The solution of the homogeneous relation (where k = 0) is immediate, [tex]u_n = Ca^n [/tex].

    I don't understand why the solution would be so 'obvious.' Can someone please show me how the given expression for u_n can be verified to be a solution of the homogeneous relation? Perhaps it will make it easier for me to understand it. Any help would be good.
  10. Aug 21, 2005 #9


    User Avatar
    Science Advisor
    Homework Helper

    If [itex]u_n = C a^n[/itex] then [itex]u_{n+1} = C a^{n+1}[/itex] and substituting into [itex]u_{n+1} = a u_n[/itex] gives

    [tex]C a^{n+1} = a \times C a^n[/tex]

    which is clearly true for any value of a. Therefore, [itex]C a^n[/itex] is the general solution.

    To obtain the solution of the homogeneous equation from scratch simply step down with the index like this:

    [tex]u_{n+1} = a u_n = a \times a u_{n-1} = a \times a \times a u_{n-2} ...[/tex]

    and so on until you get to the first index on the right side. You should see the pattern that develops.
  11. Aug 21, 2005 #10
    Thanks again for your help Tide.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook