Loading [MathJax]/extensions/tex2jax.js
MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
All Namespaces Files Functions Variables
mrffl_tvm Module Reference

Solvers for TVM problems involving lump sums, level (fixed) annuities, and geometric (growing) annuities. More...

Functions/Subroutines

real(kind=rk) pure elemental function, public fv_from_pv_n_i (pv, n, i)
 compute future value from present value (pv), number of periods (n), and an intrest rate (i).
 
real(kind=rk) pure function, public tvm_geometric_annuity_sum_a (n, g, a)
 Sum the payments from a geometric annuity.
 
integer(kind=ik) pure function, public tvm_delayed_annuity_num_payments (n, d, e)
 Return the number of payments given the period count (n), delay (d), and early end (e).
 
subroutine, public tvm_lump_sum_solve (n, i, pv, fv, unknowns, status)
 Solve for TVM parameters for a lump sum.
 
subroutine, public tvm_delayed_lump_sum_solve (n, i, pv, fv, a, d, unknowns, status)
 Solve for TVM parameters for a generalized lump sum.
 
subroutine, public tvm_delayed_lump_sum_check (n, i, pv, fv, a, d, status)
 Check the TVM parameters for a generalized lump sum.
 
subroutine, public tvm_delayed_level_annuity_solve (n, i, pv, fv, a, d, e, unknowns, status)
 Solve for TVM parameters for a level annuity.
 
subroutine, public tvm_delayed_level_annuity_check (n, i, pv, fv, a, d, e, status)
 Check TVM parameters for a level annuity.
 
subroutine, public tvm_delayed_geometric_annuity_solve (n, i, g, pv, fv, a, d, e, unknowns, status)
 Solve for TVM parameters for a geometric annuity certain.
 
subroutine, public tvm_delayed_geometric_annuity_check (n, i, g, pv, fv, a, d, e, status)
 Check TVM parameters for a geometric annuity certain.
 
subroutine, public tvm_delayed_arithmetic_annuity_solve (n, i, q, pv, fv, a, d, e, unknowns, status)
 Solve for TVM parameters for a arithmetic annuity certain.
 
subroutine, public tvm_delayed_arithmetic_annuity_check (n, i, q, pv, fv, a, d, e, status)
 Check TVM parameters for a arithmatic annuity certain.
 

Variables

real(kind=rk), parameter consistent_epsilon = 1.0e-3_rk
 Used to check equation consistency.
 

Detailed Description

Solvers for TVM problems involving lump sums, level (fixed) annuities, and geometric (growing) annuities.

Definitions and Notation
  • Annuity in advance, annuity due: Payment at beginning of each period. Ex: Rent and subscription fees.
  • Ordinary annuity, annuity in arrears, annuity-immediate: Payment at the end of each period. Ex: Mortgages and car loans.
  • Annuity certain, guaranteed annuity: The number of payments is known in advance
  • Deferred annuity: An annuity that begins payments only after a number of periods.
  • Early end annuity: An annuity that that terminates before the number of periods. This can be because the annuity was contingent; however, it is more frequently an artificial condition used to base the PV/FV computation on a different term than that for which the annuity was intended.
  • Annuity payment growth:
    • fixed, level: all payments are the same
    • growing, geometric: payments grow geometrically
    • arithmatic: payments grow linearly

In working with people from different places and from many different fields, I have discovered some of the above terminology is used differently or becomes confusing depending upon the audience. To avoid such issues, I follow the following rules in this package:

  • I avoid the adjective "fixed" with regard to annuities because it is confused with the adjectives "certain" & "guaranteed". As such, "fixed annuities" are called "level annuities" in this package.
  • I avoid the term "annuity-immediate" because many confuse it with annuities that are not "deferred" – i.e. pay immediately upon purchase. As such I use the phrase "ordinary annuity".
  • I avoid the adjectives "guaranteed" and "guarantee" with regard to annuities because they are confused with the term "non-contingent". As such I use the word "certain". In this module all annuities are certain, so it is safe to assume an annuity is certain when it's not explicity specified.
  • I avoid the adjective "growing" with regard to annuities simply because it is too generic and offends my mathematical sense of precision. Arithmetic annuities are "growing" too?!? Right?!? As such I use the term "geometric".
Approach

It's common practice in financial problem solving to produce a single set of TVM equations for a particular scenario, and then solve the resulting equation(s). For example a loan might be thought of as a single cashflow stream starting with a negative cashflow for the principal followed by sequence of negative, equal cash flows for the payments with the overall condition that the cashflow stream has a future value of zero. As an aside, this is the fundamental "TVM Equation" used by modern financial calculators – so this approach can lead to single equations that are broadly applicable to many problems.

Most TVM problems may be broken down into distinct components corresponding to well known, fundamental TVM problems. It is frequently possible to solve the overall problem by solving these smaller, well known problems in isolation. For example a loan can be thought of as two cashflow sequences: An ordinary lump sum and an ordinary annuity certain – we simply require that each of these two cashflows have equal future values.

This module encourages this second method of solving TVM problems by providing very generic TVM solvers for some very common cashflow patterns (various forms of annuities & lump sums). This allows one to mix and match the solvers as required applying them to the components of a typical TVM problem.

Annuities

The annuity solvers in this module are uniquely flexible. In most software annuities are defined as a fixed number of periods with a single payment occurring in each period such that all payments occur either at the beginning (ordinary annuities) or end (annuities due) of the period. Instead of associating payments with periods, this module ties them directly to the boundaries between periods – an \(n\) period annuity has \(n+1\) boundaries (one at time zero, one at time \(n\), and \(n-1\) between periods).

In this module the number of periods (n) and the boundaries at which the payments start (d) and end (e) are each free variables in the definition of an annuity. This allows us to handle ordinary annuities, annuities due, differed annuities, and truncated annuities with just a single solver! In addition we can use this flexibility to base PV/FV computations on a term different from the natural term of the annuity – for example we can compute the PV for an annuity due on \(n-1\) periods instead of \(n\) periods. Using this notation, we can obtain typical annuities like so:

  • An N payment ordinary annuity: n=N, d=1, e=0
  • An N payment annuity due: n=N, d=0, e=1 Note that PV/FV are normally computed for N periods for these types of annuities; however, the last payment is at the beginning of the last period. This leaves an "empty" period at the end. Sometimes it is preferable to base the computations on N-1 periods instead. To do this, use N-1 as the period count and set e=0.
  • For a delayed ordinary annuity that starts paying in period k, set d=k
  • For a delayed annuity due that starts paying in period k, set d=k-1
Lump Sums

Like the annuity solvers, the lump sum solver in this module is also uniquely flexible. Instead of the lump sum always being paid at the beginning of the first period, this library allows one to specify the payment on any period boundary.

  • For an "ordinary lump sum" use d=0 Note that some packages call this "a lump sum with payment mode `BEGIN`helper" function exists to make this easier: tvm_lump_sum_solve
  • For a "lump sum due" use d=1 Note that some packages call this "a lump sum with payment mode `END`solver". The TVM problems this module works with are each governed by a pair of formulas (one for fv and one for pv) in terms of n,i,g,q, &a. Most of the time we wantpv&fv`, so we just evaluate the formulas. Sometimes we already know pv and fv and want another variable. The "solvers" in this package provide an interface through which we may ask for any two variables to be found with respect to the others.

The primary solver functions are:

These functions operate in largely the same manner. The first 5 or 6 arguments are variables in the TVM equations. These first arguments are all intent(inout) arguments – they hold known values upon entry and hold solved values upon exit. These arguments are followed by the delay (d) argument. For annuities this is followed by the early end argument (e). Next is the unknown argument that specifies what variables we wish to solve for. Lastly is a status argument used to return errors.

delay | early end ---- variables ---- | | tvm_delayed_lump_sum_solve( n, i, pv, fv, a, d, | unknowns, status) tvm_delayed_level_annuity_solve( n, i, pv, fv, a, d, e, unknowns, status) tvm_delayed_geometric_annuity_solve( n, i, g, pv, fv, a, d, e, unknowns, status) tvm_delayed_arithmetic_annuity_solve(n, i, q, pv, fv, a, d, e, unknowns, status) | | | Used to return error codes Specifies unknown variables

Every one of these solvers works with two equations (one for pv and one for fv). As a system of two equations, we can normally solve for two unknowns. The unknowns we wish to find are specified in the unknowns argument using a sum of variable constants. For example, we would request that PV and FV be found with a sum like this:

var_pv + var_fv

For the lump sum solver there are 15 possible combinations of 1 or 2 variables:

var_n, var_n+var_i, var_n+var_pv, var_n+var_fv, var_n+var_a, var_i, var_i+var_pv, var_i+var_fv, var_i+var_a, var_pv, var_pv+var_fv, var_pv+var_a, var_fv, var_fv+var_a, var_a

For the lump sum solver any of the combinations may be solved. For others there are limitations. See the documentation for the specific solver you are using.

Note that if we only solve for one variable there is a possibility that the resulting collection of variable values may be inconsistent with the underlying equations. So if you solve for only one variable, make sure all of the other variables contain valid values. Each solver subroutine finishes by calling a corresponding consistency checker routine to insure all the values lead to consistent equations. These routines are exported from the package:

Aside from not taking the unknowns argument, the consistency checkers follow the same argument pattern as the solvers.

Solving for n.

Logically the value for n is the number of periods – a positive integer. For these routines n is allowed to be any real value so that we can solve for the variable and produce consistent results. If an integer value is required:

  1. First solve for n.
  2. Transform n to an integer in an appropriate way (perhaps ceiling for a loan).
  3. Using this integer n, now solve for two other variables in the equations (perhaps a & i for a loan). You will now have a consistent set of equations with an integer number of periods with the two variables solved for in the last step being adjusted.
Error handling

This module is intended to be used as a subsystem in larger software packages. As such it never STOPs – it simply reports error conditions back to the caller. Subroutines in this module report errors via an integer parameter named "status". If this parameter is zero after a call, then no error conditions were encountered. The error codes are allocated in blocks to each subroutine so that no subroutines share common error codes. This is intended to assist the caller in ascertaining where the problem occurred. In the code each error code is documented with a comment where the status value is set. i.e. search for the error code, and you will find the description.

Other Approaches & References

For experience more like a financial calculator, see the module tvm12.

For cashflow problems, see the module cashflows. Note it is easy to model the kinds of cashflows in this module with the cashflows module – for things like amortization tables.

Function/Subroutine Documentation

◆ fv_from_pv_n_i()

real(kind=rk) pure elemental function, public mrffl_tvm::fv_from_pv_n_i ( real(kind=rk), intent(in) pv,
integer(kind=ik), intent(in) n,
real(kind=rk), intent(in) i )

compute future value from present value (pv), number of periods (n), and an intrest rate (i).

Definition at line 232 of file mrffl_tvm.f90.

References fv_from_pv_n_i().

Referenced by fv_from_pv_n_i(), and mrffl_us_taxes::projected_tax().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tvm_geometric_annuity_sum_a()

real(kind=rk) pure function, public mrffl_tvm::tvm_geometric_annuity_sum_a ( integer(kind=ik), intent(in) n,
real(kind=rk), intent(in) g,
real(kind=rk), intent(in) a )

Sum the payments from a geometric annuity.

Ex: Sum of inflation adjusted payments.

The payment sequence is the same no matter when it starts. The first non-zero payment is \(A\), and the last non-zero payment is \( A(1+g)^{n-1}\):

\[ \begin{array}{ll} V_1 & = A \\ V_2 & = A(1+g) \\ & ... \\ V_m & = A(1+g)^{m-1} \\ & ... \\ V_n & = A(1+g)^{n-1} \\ \end{array} \]

Formulas

\[ \begin{array}{ll} P_{sum} & = P\cdot\left(\frac{(i+1)^{n}-1}{i}\right) \\ \end{array} \]

Parameters
nNumber of compounding periods (WARNING: Unlike elsewhere in this module, this is an INTEGER not a REAL)
gPayment growth rate as a percentage.
aFirst payment (Annuity)

Definition at line 263 of file mrffl_tvm.f90.

References tvm_geometric_annuity_sum_a().

Referenced by tvm_geometric_annuity_sum_a().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tvm_delayed_annuity_num_payments()

integer(kind=ik) pure function, public mrffl_tvm::tvm_delayed_annuity_num_payments ( integer(kind=ik), intent(in) n,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e )

Return the number of payments given the period count (n), delay (d), and early end (e).

Example: d 0 1 2 3 4 5 6 7 8 9 period 0 1 2 3 4 5 6 7 8 9 e 9 8 7 6 5 4 3 2 1 0 | | | d=1 -+ e=2 -+ +- n=9 -> num_payments = 1+n-e-d = 7
Parameters
nNumber of periods.
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.

Definition at line 293 of file mrffl_tvm.f90.

References tvm_delayed_annuity_num_payments().

Referenced by tvm_delayed_annuity_num_payments().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tvm_lump_sum_solve()

subroutine, public mrffl_tvm::tvm_lump_sum_solve ( real(kind=rk), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) fv,
integer(kind=ik), intent(in) unknowns,
integer(kind=ik), intent(out) status )

Solve for TVM parameters for a lump sum.

This is a simple wrapper that calls See tvm_delayed_lump_sum_solve().

Parameters
nNumber of compounding periods
iAnnual growth rate as a percentage.
pvPresent Value
fvFuture Value
unknownsWhat variable to solve for.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1193-1224.

Definition at line 310 of file mrffl_tvm.f90.

References tvm_delayed_lump_sum_solve().

Here is the call graph for this function:

◆ tvm_delayed_lump_sum_solve()

subroutine, public mrffl_tvm::tvm_delayed_lump_sum_solve ( real(kind=rk), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) fv,
real(kind=rk), intent(inout) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) unknowns,
integer(kind=ik), intent(out) status )

Solve for TVM parameters for a generalized lump sum.

\[ \begin{array}{cccc} t & V_t & \mathrm{pv}_t & \mathrm{fv}_t \\ 0 & 0 & 0 & 0 \\ ... & ... & ... & ... \\ {d-1} & 0 & 0 & 0 \\ d & a & \frac{a}{(1+i)^{d}} & a(1+i)^{n-d} \\ {d+1} & 0 & 0 & 0 \\ ... & ... & ... & ... \\ n & 0 & 0 & 0 \\ \end{array} \]

The equations this solver uses are as follows:

\[ \mathrm{fv} = a \left(1+i \right)^{n -d} \]

\[ \mathrm{pv} = a \left(1+i \right)^{-d} \]

Normally TVM software assumes a lump sum cashflow occurs at the beginning of the first period. This solver allows the cashflow to occur at the beginning or end of any period.

This solver can find any combination of 1 or 2 of the following variables: n, i, pv, fv, & a.

Parameters
nNumber of compounding periods
iAnnual growth rate as a percentage.
pvPresent Value
fvFuture Value
aThe size of the cashflow
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
unknownsWhat variables to solve for.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1161-1192.

Definition at line 365 of file mrffl_tvm.f90.

References tvm_delayed_lump_sum_check().

Referenced by tvm_lump_sum_solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tvm_delayed_lump_sum_check()

subroutine, public mrffl_tvm::tvm_delayed_lump_sum_check ( real(kind=rk), intent(in) n,
real(kind=rk), intent(in) i,
real(kind=rk), intent(in) pv,
real(kind=rk), intent(in) fv,
real(kind=rk), intent(in) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(out) status )

Check the TVM parameters for a generalized lump sum.

See tvm_delayed_lump_sum_solve() for more information regarding generalized lump sums.

Parameters
nNumber of compounding periods
iAnnual growth rate as a percentage.
pvPresent Value
fvFuture Value
aThe size of the cashflow
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1129-1160.

Definition at line 460 of file mrffl_tvm.f90.

References consistent_epsilon.

Referenced by tvm_delayed_lump_sum_solve().

Here is the caller graph for this function:

◆ tvm_delayed_level_annuity_solve()

subroutine, public mrffl_tvm::tvm_delayed_level_annuity_solve ( real(kind=rk), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) fv,
real(kind=rk), intent(inout) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(in) unknowns,
integer(kind=ik), intent(out) status )

Solve for TVM parameters for a level annuity.

\[ \begin{array}{cccc} t & V_t & \mathrm{pv}_t & \mathrm{fv}_t \\ 0 & 0 & 0 & 0 \\ ... & ... & ... & ... \\ {d-1} & 0 & 0 & 0 \\ d & a & \frac{a}{(1+i)^{d}} & a(1+i)^{n-d} \\ {d+1} & a & \frac{a}{(1+i)^{d+1}} & a(1+i)^{n-d-1} \\ ... & ... & ... & ... \\ {t} & a & \frac{a}{(1+i)^{t}} & a(1+i)^{n-t} \\ ... & ... & ... & ... \\ {n-e-1} & a & \frac{a}{(1+i)^{n-e-1}} & a(1+i)^{e+1} \\ {n-e} & a & \frac{a}{(1+i)^{n-e}} & a(1+i)^{e} \\ {n-e+1} & 0 & 0 & 0 \\ ... & ... & ... & ... \\ n & 0 & 0 & 0 \\ \end{array} \]

Total pv & fv are given by:

\[ \mathrm{fv} = \sum_{t=d}^{n-e} a(1+i)^{n-t} \]

\[ \mathrm{pv} = \sum_{t=d}^{n-e} \frac{a}{(1+i)^{t}} \]

The equations this solver uses are as follows:

\[ \mathrm{fv} = a\frac{\left(1+i \right)^{n +1-d}-\left(1+i \right)^{d} }{i} \]

\[ \mathrm{pv} = a\frac{\left(1+i \right)^{1-d} -\left(1+i \right)^{-n+d}}{i} \]

This routine is capable of searching for any combination of 1 or 2 of the following variables: n, i, pv, fv, & a

Solving for i
When possible a closed for solution is used. In some cases (var_i+var_fv, var_i+var_pv, var_i+var_n when d or e is greater than 1) bisection is used to numerically solve for i. When bisection is used, this routine will search for values for i that are within the following intervals (in the order listed): [zero_epsilon, 99999], [-100+zero_epsilon, -zero_epsilon], and [-99999, -100-zero_epsilon] In other words, it can find values of i that are between -99999 and 99999 and at least zero_epsilon away from 0% and 100%. If the value for i is outside these ranges, then no solution will be found. It is also possible that even if a solution exists inside these ranges that the search algorithm may fail. If solutions exist in more than one range, then the first one found is used.
Warning
Solutions are unreliable when i is less than -100%.
Parameters
nNumber of compounding periods
iAnnual growth rate as a percentage. When solving for this value only POSITIVE values are found.
pvPresent Value
fvFuture Value
aPayment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
unknownsWhat variable(s) to solve for. Should be a sum of var_? constants.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1097-1128.

Definition at line 561 of file mrffl_tvm.f90.

References sf_i_no_fv(), sf_i_no_n(), sf_i_no_pv(), and tvm_delayed_level_annuity_check().

Here is the call graph for this function:

◆ tvm_delayed_level_annuity_check()

subroutine, public mrffl_tvm::tvm_delayed_level_annuity_check ( real(kind=rk), intent(in) n,
real(kind=rk), intent(in) i,
real(kind=rk), intent(in) pv,
real(kind=rk), intent(in) fv,
real(kind=rk), intent(in) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(out) status )

Check TVM parameters for a level annuity.

Parameters
nNumber of compounding periods
iAnnual growth rate as a percentage. When solving for this value only POSITIVE values are found.
pvPresent Value
fvFuture Value
aPayment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1065-1096.

Definition at line 680 of file mrffl_tvm.f90.

References consistent_epsilon.

Referenced by tvm_delayed_level_annuity_solve().

Here is the caller graph for this function:

◆ tvm_delayed_geometric_annuity_solve()

subroutine, public mrffl_tvm::tvm_delayed_geometric_annuity_solve ( real(kind=rk), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) g,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) fv,
real(kind=rk), intent(inout) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(in) unknowns,
integer(kind=ik), intent(out) status )

Solve for TVM parameters for a geometric annuity certain.

\[ \begin{array}{cccc} t & V_t & \mathrm{pv}_t & \mathrm{fv}_t \\ 0 & 0 & 0 & 0 \\ ... & ... & ... & ... \\ {d-1} & 0 & 0 & 0 \\ d & a(1+g)^{0} & a\frac{(1+g)^{0}}{(1+i)^{d}} & a(1+g)^{0}(1+i)^{n-d} \\ {d+1} & a(1+g)^{1} & a\frac{(1+g)^{1}}{(1+i)^{d+1}} & a(1+g)^{1}(1+i)^{n-d-1} \\ ... & ... & ... & ... \\ {t} & a(1+g)^{t-d} & a\frac{(1+g)^{t-d}}{(1+i)^{t}} & a(1+g)^{t-d}(1+i)^{n-t} \\ ... & ... & ... & ... \\ {n-e-1} & a(1+g)^{n-e-1-d} & a\frac{(1+g)^{n-e-1-d}}{(1+i)^{n-e-1}} & a(1+g)^{n-e-d-1}(1+i)^{e+1} \\ {n-e} & a(1+g)^{n-e-d} & a\frac{(1+g)^{n-e-d}}{(1+i)^{n-e}} & a(1+g)^{n-e-d}(1+i)^{e} \\ {n-e+1} & 0 & 0 & 0 \\ ... & ... & ... & ... \\ n & 0 & 0 & 0 \\ \end{array} \]

Total pv & fv are given by:

\[ \mathrm{fv} = \sum_{t=d}^{n-e} a(1+g)^{t-d}(1+i)^{n-t} \]

\[ \mathrm{pv} = \sum_{t=d}^{n-e} a\frac{(1+g)^{t-d}}{(1+i)^{t}} \]

When \(i\ne g\), the total pv & fv are given by:

\[ \mathrm{fv} = a \frac{\left(1+g \right)^{1+n-e-d} \left(1+i \right)^{e}-\left(1+i\right)^{1+n-d}}{g -i} \]

\[ \mathrm{pv} = a \frac{\left(1+g \right) \left(\frac{1+g}{1+i}\right)^{n -e}-\left(\frac{1+g}{1+i}\right)^{d} \left(1+i \right)}{(g-i)(1+g)^{-d}} \]

When \(i=g\), the total pv & fv are given by:

\[ \mathrm{fv} = a \left(1+n-e-d\right) \left(1+i\right)^{n-d} \]

\[ \mathrm{pv} = a \left(1+n-e-d\right) \left(1+i\right)^{-d} \]

This routine can solve for var_n, var_n+var_fv, and any combination of two or fewer of the following: var_a, var_fv, var_pv

Parameters
nNumber of compounding periods
iDiscount rate as a percentage.
gPayment growth rate as a percentage.
pvPresent Value
fvFuture Value
aFirst payment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
unknownsWhat variables to solve for.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1033-1064.

Definition at line 780 of file mrffl_tvm.f90.

References tvm_delayed_geometric_annuity_check().

Here is the call graph for this function:

◆ tvm_delayed_geometric_annuity_check()

subroutine, public mrffl_tvm::tvm_delayed_geometric_annuity_check ( real(kind=rk), intent(in) n,
real(kind=rk), intent(in) i,
real(kind=rk), intent(in) g,
real(kind=rk), intent(in) pv,
real(kind=rk), intent(in) fv,
real(kind=rk), intent(in) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(out) status )

Check TVM parameters for a geometric annuity certain.

Parameters
nNumber of compounding periods
iDiscount rate as a percentage.
gPayment growth rate as a percentage.
pvPresent Value
fvFuture Value
aFirst payment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
statusReturns status of computation. 0 if everything worked. Range: 0 & 1001-1032.

Definition at line 871 of file mrffl_tvm.f90.

References consistent_epsilon.

Referenced by tvm_delayed_geometric_annuity_solve().

Here is the caller graph for this function:

◆ tvm_delayed_arithmetic_annuity_solve()

subroutine, public mrffl_tvm::tvm_delayed_arithmetic_annuity_solve ( real(kind=rk), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) q,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) fv,
real(kind=rk), intent(inout) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(in) unknowns,
integer(kind=ik), intent(out) status )

Solve for TVM parameters for a arithmetic annuity certain.

\[ \begin{array}{cccc} t & V_t & \mathrm{pv}_t & \mathrm{fv}_t \\ 0 & 0 & 0 & 0 \\ ... & ... & ... & ... \\ {d-1} & 0 & 0 & 0 \\ d & a+q\cdot 0 & \frac{a+q\cdot 0}{(1+i)^{d}} & (a+q\cdot 0)(1+i)^{n-d} \\ {d+1} & a+q\cdot 1 & \frac{a+q\cdot 1}{(1+i)^{d+1}} & (a+q\cdot 1)(1+i)^{n-d-1} \\ ... & ... & ... & ... \\ {t} & a+q\cdot (t-d) & \frac{a+q\cdot (t-d)}{(1+i)^{t}} & (a+q\cdot (t-d))(1+i)^{n-t} \\ ... & ... & ... & ... \\ {n-e-1} & a+q\cdot (n-e-1-d) & \frac{a+q\cdot (n-e-1-d)}{(1+i)^{n-e-1}} & (a+q\cdot (n-e-1-d))(1+i)^{e+1} \\ {n-e} & a+q\cdot (n-e-d) & \frac{a+q\cdot (n-e-d)}{(1+i)^{n-e}} & (a+q\cdot (n-e-d))(1+i)^{e} \\ {n-e+1} & 0 & 0 & 0 \\ ... & ... & ... & ... \\ n & 0 & 0 & 0 \\ \end{array} \]

Total pv & fv are given by:

\[ \mathrm{fv} = \sum_{t=d}^{n-e} (a+q t-q d)(1+i)^{n-t} \]

\[ \mathrm{pv} = \sum_{t=d}^{n-e} \frac{a+q t-q d}{(1+i)^{t}} \]

The equations this solver uses are as follows:

\[ \mathrm{fv} = \frac{\left(1+i \right)^{1+n -d} \left(a i +q \right)-\left(1+i \right)^{e} \left(\left(\left(1+n -e -d \right) q +a \right) i +q \right)}{i^{2}} \]

\[ \mathrm{pv} = \frac{\left(\left(\left(d -1-n +e \right) q -a \right) i -q \right) \left(\frac{1}{1+i}\right)^{n -e}+\left(a i +q \right) \left(1+i \right) \left(\frac{1}{1+i}\right)^{d}}{i^{2}} \]

This routine can solve one or two variables except for the following combinations: var_n+var_i, var_n+var_q, var_n+var_pv, var_n+var_fv, var_i+var_pv, var_i+var_fv, var_q+var_a

Parameters
nNumber of compounding periods
iDiscount rate as a percentage.
qPayment growth rate (added at each payment)
pvPresent Value
fvFuture Value
aFirst payment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
unknownsWhat variables to solve for.
statusReturns status of computation. 0 if everything worked. Range: 0 & 4129-4160.

Definition at line 987 of file mrffl_tvm.f90.

References tvm_delayed_arithmetic_annuity_check().

Here is the call graph for this function:

◆ tvm_delayed_arithmetic_annuity_check()

subroutine, public mrffl_tvm::tvm_delayed_arithmetic_annuity_check ( real(kind=rk), intent(in) n,
real(kind=rk), intent(in) i,
real(kind=rk), intent(in) q,
real(kind=rk), intent(in) pv,
real(kind=rk), intent(in) fv,
real(kind=rk), intent(in) a,
integer(kind=ik), intent(in) d,
integer(kind=ik), intent(in) e,
integer(kind=ik), intent(out) status )

Check TVM parameters for a arithmatic annuity certain.

Parameters
nNumber of compounding periods
iDiscount rate as a percentage.
qPayment growth rate (added at each payment)
pvPresent Value
fvFuture Value
aFirst payment (Annuity)
dDelay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j.
eEarly end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n.
statusReturns status of computation. 0 if everything worked. Range: 0 & 4097-4128.

Definition at line 1061 of file mrffl_tvm.f90.

References consistent_epsilon.

Referenced by tvm_delayed_arithmetic_annuity_solve().

Here is the caller graph for this function:

Variable Documentation

◆ consistent_epsilon

real(kind=rk), parameter mrffl_tvm::consistent_epsilon = 1.0e-3_rk
private