Function rate

  • Compute the rate of interest per period


    • nper: number

      Number of compounding periods

    • pmt: number


    • 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)




    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)


    • 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.


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

Generated using TypeDoc