Module periods

Source
Expand description

Number of periods calculations. Given a periodic rate, present value, and future value, find the number of periods needed to satisfy the equation.

For most common usages, we recommend the periods_solution function.

§Concepts

Suppose we invest $100 at 10% annual interest. After one year the investment is worth $110. After two years it’s worth $110 plus 10% or $121, and so on:

Here n is the number of periods, in this case years, and fv is the future value, or the value of the investment after some number of years. After 12 years the investment would grow to a little over $300.

But suppose our goal is to reach $250 and we need to know exactly how many years that will take. This is where the periods calculations come in. They find the point where an investment reaches some fixed value:

Here the investment reaches $250 after 9.61 years.

The same ideas apply with a negative rate. Suppose we have a value that starts at $100 and declines by 10% per year. At what point does the value fall to $70?

After 3.39 periods the value is $70.

§Formulas

§Simple Compounding

With simple compound interest the number of periods is calculated with:

Or using some more common variable names:

n is often used for the number of periods, though it may be t for time if each period is assumed to be one year as in continuous compounding. r is the periodic rate, though this may appear as i for interest.

Throughout this crate we use pv for present value and fv for future value. You may see these values called P for principal in some references.

Within the TvmSolution struct we record the formula used for the particular calculation using both concrete values and symbols. For the example above with $100 growing at 10%, where we want to end up with $250 the struct contains:

formula: "9.61 = log(250.0000 / 100.0000, base 1.100000)",
symbolic_formula: "n = log(-fv / pv, base (1 + r))",

§Continuous Compounding

With continuous compounding it’s:

or:

With continuous compounding the period is assumed to be years and t (time) is often used as the variable name. Within this crate we stick with n for the number of periods so that it’s easier to compare formulas when they’re printed as simple text as part of the TvmSolution struct, as in:

formula: "9.16 = ln(250.0000 / 100.0000) / 0.100000",
symbolic_formula: "n = ln(fv / pv) / r",

Functions§

periods
Returns the number of periods given a periodic rate along with the present and future values, using simple compounding.
periods_solution
Calculates the number of periods given a periodic rate along with the present and future values using simple compounding; and builds a struct with the input values, an explanation of the formula, and the option to calculate the period-by-period values.