MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
|
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. | |
Solvers for TVM problems involving lump sums, level (fixed) annuities, and geometric (growing) annuities.
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:
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.
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:
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.
fv
and one for pv
) in terms of n,
i,
g,
q, &
a. Most of the time we want
pv&
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:
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.
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.
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().
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} \]
n | Number of compounding periods (WARNING: Unlike elsewhere in this module, this is an INTEGER not a REAL) |
g | Payment growth rate as a percentage. |
a | First payment (Annuity) |
Definition at line 263 of file mrffl_tvm.f90.
References tvm_geometric_annuity_sum_a().
Referenced by tvm_geometric_annuity_sum_a().
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
n | Number of periods. |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early 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().
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().
n | Number of compounding periods |
i | Annual growth rate as a percentage. |
pv | Present Value |
fv | Future Value |
unknowns | What variable to solve for. |
status | Returns 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().
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.
n | Number of compounding periods |
i | Annual growth rate as a percentage. |
pv | Present Value |
fv | Future Value |
a | The size of the cashflow |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
unknowns | What variables to solve for. |
status | Returns 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().
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.
n | Number of compounding periods |
i | Annual growth rate as a percentage. |
pv | Present Value |
fv | Future Value |
a | The size of the cashflow |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
status | Returns 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().
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
n | Number of compounding periods |
i | Annual growth rate as a percentage. When solving for this value only POSITIVE values are found. |
pv | Present Value |
fv | Future Value |
a | Payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
unknowns | What variable(s) to solve for. Should be a sum of var_? constants. |
status | Returns 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().
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.
n | Number of compounding periods |
i | Annual growth rate as a percentage. When solving for this value only POSITIVE values are found. |
pv | Present Value |
fv | Future Value |
a | Payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
status | Returns 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().
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
n | Number of compounding periods |
i | Discount rate as a percentage. |
g | Payment growth rate as a percentage. |
pv | Present Value |
fv | Future Value |
a | First payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
unknowns | What variables to solve for. |
status | Returns 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().
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.
n | Number of compounding periods |
i | Discount rate as a percentage. |
g | Payment growth rate as a percentage. |
pv | Present Value |
fv | Future Value |
a | First payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
status | Returns 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().
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
n | Number of compounding periods |
i | Discount rate as a percentage. |
q | Payment growth rate (added at each payment) |
pv | Present Value |
fv | Future Value |
a | First payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
unknowns | What variables to solve for. |
status | Returns 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().
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.
n | Number of compounding periods |
i | Discount rate as a percentage. |
q | Payment growth rate (added at each payment) |
pv | Present Value |
fv | Future Value |
a | First payment (Annuity) |
d | Delay from time zero. i.e. d=0 is the beginning of period 1 otherwise d=j is the end if period j. |
e | Early end counted from time end (t=n). i.e. e=0 means the last payment is at end of period n. |
status | Returns 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().
|
private |
Used to check equation consistency.
Definition at line 214 of file mrffl_tvm.f90.
Referenced by tvm_delayed_arithmetic_annuity_check(), tvm_delayed_geometric_annuity_check(), tvm_delayed_level_annuity_check(), and tvm_delayed_lump_sum_check().