payment:
1 2 3 4 5 6 7 8 9 |
while(minRate < maxRate - 0.0001){ midRate = (maxRate + minRate) / 2; result = (loan * midRate * (1 + midRate) ^ period)/((1 + midRate)^period - 1) ) - mthPay; if(result < 0) { minRate = midRate; }else{ maxRate = midRate; } } |
rec:
1 2 3 4 5 6 7 8 9 10 11 12 |
do { Xi= Xi+1; Xi+1 = g(Xi, r); if(Xi+1 != 0){ ea = abs((Xi+1 - Xi) / Xi+1) * 100; } iter++; } while(ea > es ); ........... public static double g(double x, double r){ return x * (2 - x * r); } |