Solves the linear inhomogeneous recurrence relation

You're viewing an older version of this page (#593). View the current version.

View versions (1)

Interface

#include <codecogs/maths/discrete/recurrence/linear/inhomogeneous/first_order.h>

using namespace Maths::Discrete::Recurrence::Linear::Inhomogeneous;

The solution to an inhomogenous recurrence relationship of the form

u_{n+1} = a u_n + b
(1)

where u_0 is constant is

u_n = \left ( u_0 + \frac{b}{a-1} \right ) a^n - \frac{b}{a-1}
(2)
This part is only visible to registered users. Sign in to see it.

Example 1

The annual birth rate of a small island is 1.1 per capita. There is also a constant influx of 10 new imigrants to the island each year. If the initial population is 580, what is the population after each year for the next 10 years

#include <stdio.h>
#include <codecogs/maths/discrete/recurrence/linear/inhomogeneous/first_order.h>

using namespace Maths::Recurrence::Linear::InHomogeneous;
int main()
{
  double intial_pop=580;  // an initial population
  double birth_rate=1.1;   // average birthrate per capita
  double imigration=10;   // direct imigration
  for(int i=0;i<=10;i++)
    printf("\n Year=%d  Population=%lf",i, first_order(intial_pop, birth_rate, imigration, i));
  return 0;
}

Output

Year=0  Population=580.000000
 Year=1  Population=648.000000
 Year=2  Population=722.800000
 Year=3  Population=805.080000
 Year=4  Population=895.588000
 Year=5  Population=995.146800
 Year=6  Population=1104.661480
 Year=7  Population=1225.127628
 Year=8  Population=1357.640391
 Year=9  Population=1503.404430
 Year=10  Population=1663.744873

Parameters

u0
The first (initial) term of the series.
a
Homogeous factor - multiplier for each additional term of the recurrence series.
b
Inhomegeneous factor - additional constant added at each step of the recurrence.
n
The number of terms from the recursive series to evaluate.
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

u0
a
b
n
Result