Function: math-compute-nper
math-compute-nper is a byte-compiled function defined in
calc-fin.el.gz.
Signature
(math-compute-nper RATE PMT AMOUNT LUMP BFLAG)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-fin.el.gz
(defun math-compute-nper (rate pmt amount lump bflag)
(and lump (math-zerop lump)
(setq lump nil))
(and lump (math-zerop pmt)
(setq amount lump
lump nil
bflag 'l))
(or (math-objectp rate) (and math-expand-formulas (null lump))
(math-reject-arg rate 'numberp))
(and (math-zerop rate)
(math-reject-arg rate 'nonzerop))
(or (math-objectp pmt) (and math-expand-formulas (null lump))
(math-reject-arg pmt 'numberp))
(or (math-objectp amount) (and math-expand-formulas (null lump))
(math-reject-arg amount 'numberp))
(if lump
(progn
(or (math-objectp lump)
(math-reject-arg lump 'numberp))
(let ((root (math-find-root (list 'calcFunc-eq
(list (if bflag
'calcFunc-pvb
'calcFunc-pv)
rate
'(var DUMMY var-DUMMY)
pmt
lump)
amount)
'(var DUMMY var-DUMMY)
'(intv 3 0 100)
t)))
(if (math-vectorp root)
(nth 1 root)
root)))
(math-with-extra-prec 2
(let ((temp (if (eq bflag 'l)
(math-div amount pmt)
(math-sub 1 (math-div (math-mul amount rate)
(if bflag
(math-mul pmt (math-add 1 rate))
pmt))))))
(if (or (math-posp temp) math-expand-formulas)
(math-neg (calcFunc-log temp (math-add 1 rate)))
(math-reject-arg pmt "*Payment too small to cover interest rate"))))))