1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crateRSLifeResult;
use crateeff_i_to_nom_i;
use builder;
/// Annuity-certain in arrears
///
/// Present value of an annuity-certain in arrears: $1 per period, paid m times per year for n years, starting after t periods.
///
/// # Formula
/// ```text
/// ₜ| aₙ⁽ᵐ⁾ = vᵗ · (1 - vⁿ) / i⁽ᵐ⁾
/// ```
/// where:
/// - `v = 1/(1+i)` is the discount factor
/// - `i` is the effective annual interest rate
/// - `i⁽ᵐ⁾` is the nominal rate convertible m times per year
/// - `n` is the number of periods
/// - `t` is the deferral period (default 0)
/// - `m` is the number of payments per year (default 1)
///
/// # Examples
///
/// ## Basic Annuity-Certain in Arrears
/// ```rust
/// # use rslife::prelude::*;
/// let annuity = an().i(0.03).n(10).call()?;
/// println!("Annuity-certain in arrears: {:.6}", annuity);
/// # RSLifeResult::Ok(())
/// ```
/// Annuity-certain due
///
/// Present value of an annuity-certain due: $1 per period, paid m times per year for n years, starting immediately (first payment at time 0).
///
/// # Formula
/// ```text
/// ₜ| äₙ⁽ᵐ⁾ = vᵗ · (1 - vⁿ) / d⁽ᵐ⁾
/// ₜ| äₙ⁽ᵐ⁾ = ₜ| aₙ⁽ᵐ⁾ · i⁽ᵐ⁾ / d⁽ᵐ⁾
/// ```
/// where:
/// - `v = 1/(1+i)` is the discount factor
/// - `i` is the effective annual interest rate
/// - `d⁽ᵐ⁾` is the nominal rate of discount convertible m times per year
/// - `i⁽ᵐ⁾` is the nominal rate convertible m times per year
/// - `n` is the number of periods
/// - `t` is the deferral period (default 0)
/// - `m` is the number of payments per year (default 1)
///
/// # Examples
///
/// ## Basic Annuity-Certain Due
/// ```rust
/// # use rslife::prelude::*;
/// let annuity_due = aan().i(0.03).n(10).call()?;
/// println!("Annuity-certain due: {:.6}", annuity_due);
/// # RSLifeResult::Ok(())
/// ```