Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 46 ยท Discrete Dynamical Models

Difference Equations and Their Solutions

Solve linear difference equations x(n+1) = r x(n) + b in closed form, find equilibria and stability, price a loan, and meet Fibonacci and the golden ratio.

When time moves in steps, the language of change is the difference equation: a rule linking each value to the ones before it. In this lesson you will master the most important case, the linear rule, because it is both common and completely solvable. Knowing it well also prepares you for the nonlinear ones in the next lesson.

What you will learn

  • How to solve xโ‚™โ‚Šโ‚ = r xโ‚™ + b with a closed formula
  • How to find the equilibrium and decide whether it is stable
  • How to build and use a loan model
  • How second-order rules such as Fibonacci lead to the golden ratio

Key terms

Difference equation (recurrence): a rule that expresses xโ‚™โ‚Šโ‚ using earlier values.

Closed form: a formula for xโ‚™ that needs no earlier values.

Equilibrium (fixed point) x*: a value with f(x*) = x*.

Stable equilibrium: nearby starting values move toward it as n grows.

Amortization: paying off a loan with regular instalments.

The pure growth rule

The simplest rule is xโ‚™โ‚Šโ‚ = r xโ‚™. Apply it repeatedly: xโ‚ = r xโ‚€, xโ‚‚ = rยฒ xโ‚€, and so xโ‚™ = xโ‚€ rโฟ. This is geometric growth or decay, depending on r:

  • r > 1: grows without bound
  • r = 1: stays constant
  • 0 < r < 1: decays toward 0
  • โˆ’1 < r < 0: decays toward 0 while flipping sign each step
  • r < โˆ’1: grows while flipping sign
Three sequences starting at 1 with r = 1.2 growing, r = 1 constant and r = 0.8 decaying, next to the solution x(n) = x0 r^n
The value of r decides the whole story for the linear rule.

Adding a constant: x(n+1) = r x(n) + b

Real systems add or remove a fixed amount each step: a monthly deposit, a loan payment (negative b), immigration, harvesting. The rule becomes xโ‚™โ‚Šโ‚ = r xโ‚™ + b.

Step 1: find the equilibrium. Set x* = r x* + b, so x* = b / (1 โˆ’ r) (when r โ‰  1).

Step 2: measure distance from equilibrium. Let dโ‚™ = xโ‚™ โˆ’ x*. Then

dโ‚™โ‚Šโ‚ = xโ‚™โ‚Šโ‚ โˆ’ x* = (r xโ‚™ + b) โˆ’ (r x* + b) = r (xโ‚™ โˆ’ x*) = r dโ‚™

The distance obeys the pure rule, so dโ‚™ = r^n dโ‚€. Therefore

xโ‚™ = x* + rโฟ (xโ‚€ โˆ’ x*)

Stability. If |r| < 1, rโฟ โ†’ 0 and the sequence converges to x* (stable). If |r| > 1 it runs away (unstable).

Example: xโ‚™โ‚Šโ‚ = 0.8 xโ‚™ + 4. Here x* = 4/(1 โˆ’ 0.8) = 20. From xโ‚€ = 100: xโ‚™ = 20 + 80 ยท 0.8โฟ. From xโ‚€ = 0: xโ‚™ = 20 โˆ’ 20 ยท 0.8โฟ. Both approach 20.

Python Closed form versus iteration

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Starting at the equilibrium (xโ‚€ = 20) the sequence never moves, which is exactly what "fixed point" means.

Case study: a loan

You borrow Bโ‚€ at monthly interest rate i and repay P each month. Interest is added to the balance, then you pay:

Bโ‚™โ‚Šโ‚ = (1 + i) Bโ‚™ โˆ’ P

This is our rule with r = 1 + i and b = โˆ’P. The "equilibrium" is x* = P/i: the balance at which interest exactly cancels the payment. Because r > 1, it is unstable. If Bโ‚€ < P/i, the balance falls to zero (the loan is repaid); if Bโ‚€ > P/i, the balance grows forever. Solving for zero balance after N payments gives the standard instalment formula:

P = Bโ‚€ i / (1 โˆ’ (1 + i)^(โˆ’N))

With Bโ‚€ = 10,000, i = 0.5% per month (6% a year, compounded monthly) and N = 60 months, the payment is about 193.33. Check it with a simulation, and look at how each payment splits into interest and principal. (This is an arithmetic model, not financial advice. Real loans have fees and differences in how interest is quoted.)

Python Loan model: instalment and the interest/principal split

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Second-order rules: Fibonacci

Some rules use the two previous values. The Fibonacci sequence Fโ‚™โ‚Šโ‚ = Fโ‚™ + Fโ‚™โ‚‹โ‚ (from Leonardo of Pisa's rabbit puzzle, 1202) is the famous one. Try a solution of the form Fโ‚™ = ฮปโฟ. Substituting gives ฮปยฒ = ฮป + 1, the characteristic equation, with roots

ฮป = (1 ยฑ โˆš5) / 2, i.e. ฯ† โ‰ˆ 1.618 (the golden ratio) and ฯˆ โ‰ˆ โˆ’0.618.

The general solution is Fโ‚™ = A ฯ†โฟ + B ฯˆโฟ, and fitting Fโ‚€ = 0, Fโ‚ = 1 gives Binet's formula Fโ‚™ = (ฯ†โฟ โˆ’ ฯˆโฟ)/โˆš5. Since |ฯˆ| < 1, the second term fades and Fโ‚™ grows like ฯ†โฟ: the ratio of consecutive terms tends to the golden ratio.

Iteration also solves equations. Newton's method for โˆš2 uses the rule xโ‚™โ‚Šโ‚ = (xโ‚™ + 2/xโ‚™)/2, whose fixed point is โˆš2. The sequence converges extremely fast, roughly doubling the number of correct digits each step.

Python Fibonacci ratios and Newton's square-root rule

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common misconceptions

"A closed form is always better." It is great for insight, but when no closed form exists (the logistic map, next lesson) simulation is the honest tool.

"If r is close to 1, nothing much happens." Small differences compound. With r = 1.01 over 100 steps the value grows by a factor of about 2.7; with r = 0.99 it shrinks to about 0.37.

"The loan equilibrium P/i is where the loan ends." It is the unstable balance where interest equals the payment. Below it, you pay off; above it, you fall further behind.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. The closed form of x(n+1) = r x(n) with x(0) = x0 is:

    Each step multiplies by r, so after n steps the factor is r^n.
  2. 2. For x(n+1) = 0.5 x(n) + 3, what is the equilibrium?

    x* = b / (1 - r) = 3 / 0.5 = 6.
  3. 3. An equilibrium of x(n+1) = r x(n) + b with r = -0.5 is:

    |r| = 0.5 < 1, so the distance from equilibrium shrinks, flipping sign each step.
  4. 4. In the loan model B(n+1) = (1 + i) B(n) - P, the 'equilibrium' P/i is:

    Here r = 1 + i > 1, so deviations grow. That is why a loan is either paid off or snowballs.
  5. 5. Which number does F(n+1)/F(n) approach for Fibonacci numbers?

    The dominant root of lambda^2 = lambda + 1 is (1 + sqrt 5)/2, about 1.618.

Summary

  • xโ‚™โ‚Šโ‚ = r xโ‚™ gives xโ‚™ = xโ‚€ rโฟ; the size of r decides growth, constancy or decay.
  • xโ‚™โ‚Šโ‚ = r xโ‚™ + b has equilibrium x* = b/(1 โˆ’ r) and solution xโ‚™ = x* + rโฟ (xโ‚€ โˆ’ x*); it is stable when |r| < 1.
  • A loan is the same rule with r = 1 + i and b = โˆ’P; its instalment formula comes from requiring zero balance after N payments.
  • Second-order rules use a characteristic equation; Fibonacci gives the golden ratio.

Next: The Logistic Map and Chaos