2013-11-15 29 views
2

我需要一個公式來計算利率支付涉及利率,其他相關公式如下:如何找到支付

FV = (PMT * k/ip) - Math.pow((1 + ip), N) * (PV + PMT * k/ip); 

PV = (PMT * k/ip - FV) * 1/Math.pow(1 + ip, N) - PMT * k/ip; 

PMT = (PV + ((PV+FV)/(Math.pow((1+ip),N)-1))) * ((-ip)/k); 

ip = ???? 

Where: 

PV = Present Value 

ip = Interest Rate per period 

N = Number of periods 

PMT = Payment 

k = 1 if payment is made at the end of the period; 1 + ip if made at the beginning of the period 

FV = Future Value 

有人曾問上Calculate interest rate in Java (TVM)同樣的問題,但仍然無法找到正確答案。

提出的解決方案是將替換所有已知的變量到下面的公式,然後選擇IP一系列的值,直到表達式等於零:

0 = (PV * Math.pow(1 + ip, N)) + ((PMT * k) * (Math.pow(1 + ip, N) - 1)/ip) + FV 

如何創建一個函數來完成這樣的迭代或有沒有簡單的公式來解決這個問題?

+0

我不知道你的公式是正確的。你在哪裏得到它們?無論如何,這些方程不能明確地解決'ip'問題。一種方法是用你想要的任何方程來使用牛頓的方法。 – Teepeemm

+0

這些公式經過測試和正確,它來自http://www.getobjects.com/Components/Finance/TVM/formulas.html – xpw

回答

0

該公式無法解決ip;你被困在你選擇的根發現者身上。 Newton's Method將如下:

static double implicit(double PV, double ip, double N, double PMT, double k, double FV) { 
    return PV * Math.pow(1+ip,N) 
     + PMT * k * (Math.pow(1+ip,N)-1)/ip + FV; 
} 

static double dImplicit_dIp(double PV, double ip, double N, double PMT, double k, double FV) { 
    return PV * N * Math.pow(1+ip,N-1) 
     + PMT * k * (ip * N * Math.pow(1+ip,N-1) - Math.pow(1+ip,N) + 1)/(ip*ip); 
} 

static double getIp(double PV, double N, double PMT, double k, double FV) { 
    double ip = .1; 
    double ipLast; 
    do { 
     ipLast = ip; 
     ip -= implicit(PV,ip,N,PMT,k,PV)/dImplicit_dIp(PV,ip,N,PMT,k,PV); 
    } while (Math.abs(ip-ipLast) > .00001); 
    return ip; 
}