Overview
For modeling purposes, it is easier to convert calculations to continuous time compounding. That is, we assume that money is continuously compounded at a continuous rate.
The formula for the present value of a cash stream with an annual rate of {% r %} and {% n %} periods per year is
{% A = P \times (1 + r/n)^{nt} %}
Next, take the limit as the number of periods goes to infinity
{% \lim _{n \to \infty} \: P \times (1 + r/n)^{nt} = P e^{rt} %}
This yields
{% P_n = P_0 \times e^{r \times t} %}
Implementation
The following code utilizes the continuous compounding library to calculate present value.
let futureValue = 100 * Math.exp(rate*time)
let pv = await import('/lib/finance/fixed-income/present-value/v1.0.0/continuous.mjs');
let futureValue = pv.value(100, time, rate);
//alternate computation
let futureValue = pv.value({
value:100,
time:time,
rate:0.03
});