Function rate

  • Compute the rate of interest per period

    Parameters

    • nper: number

      Number of compounding periods

    • pmt: number

      Payment

    • pv: number

      Present value

    • fv: number

      Future value

    • when: PaymentDueTime = PaymentDueTime.End

      When payments are due ('begin' or 'end')

    • guess: number = 0.1

      Starting guess for solving the rate of interest

    • tol: number = 1e-6

      Required tolerance for the solution

    • maxIter: number = 100

      Maximum iterations in finding the solution

    Returns number

    the rate of interest per period (or NaN if it could not be computed within the number of iterations provided)

    Since

    v0.0.16

    Notes

    Use Newton's iteration until the change is less than 1e-6 for all values or a maximum of 100 iterations is reached. Newton's rule is:

    r_{n+1} = r_{n} - g(r_n)/g'(r_n)
    

    where:

    • g(r) is the formula
    • g'(r) is the derivative with respect to r.

    The rate of interest is computed by iteratively solving the (non-linear) equation:

    fv + pv * (1+rate) ** nper + pmt * (1+rate * when) / rate * ((1+rate) ** nper - 1) = 0
    

    for `rate.

    References

    Wheeler, D. A., E. Rathke, and R. Weir (Eds.) (2009, May).

Generated using TypeDoc