first order
Solves the linear inhomogeneous recurrence relation
Controller: john
Interface
C++
First Order
doublefirst_order( | double | u0 | |
double | a | ||
double | b | ||
int | n | ) |
Purchase a Licence for more information.
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.
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.