参考来源: https://www.experts-exchange.com/articles/1948/A-Guide-to-the-PMT-FV-IPMT-and-PPMT-Functions.html
pmt计算公式:
double pmt(double r, int nper, double pv, double fv, int type) {
double pmt = r / (Math.pow(1 + r, nper) - 1)
* -(pv * Math.pow(1 + r, nper) + fv); return pmt;
}
ppmt计算公式:
double ppmt(double r, int per, int nper, double pv, double fv, int type) {
return pmt(r, nper, pv, fv, type) - ipmt(r, per, nper, pv, fv, type);
}
ipmt计算公式
double ipmt(double r, int per, int nper, double pv, double fv, int type) { double ipmt = fv(r, per - 1, pmt(r, nper, pv, fv, type), pv, type) * r; if (type == 1) ipmt /= (1 + r); return ipmt;
}
fv计算公式:
double fv(double r, int nper, double c, double pv, int type) {
double fv = -(c * (Math.pow(1 + r, nper) - 1) / r + pv
* Math.pow(1 + r, nper)); return fv;
}