Class Irr
java.lang.Object
org.apache.poi.ss.formula.functions.Irr
- All Implemented Interfaces:
Function
Calculates the internal rate of return.
Syntax is IRR(values) or IRR(values,guess)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Irr
public Irr()
-
-
Method Details
-
evaluate
- Specified by:
evaluatein interfaceFunction- Parameters:
args- the evaluated function arguments. Empty values are represented withBlankEvalorMissingArgEval, nevernull.srcRowIndex- row index of the cell containing the formula under evaluationsrcColumnIndex- column index of the cell containing the formula under evaluation- Returns:
- The evaluated result, possibly an
ErrorEval, nevernull. Note - Excel uses the error code #NUM! instead of IEEE NaN, so when numeric functions evaluate toDouble.NaNbe sure to translate the result toErrorEval.NUM_ERROR.
-
irr
public static double irr(double[] income) Computes the internal rate of return using an estimated irr of 10 percent.- Parameters:
income- the income values.- Returns:
- the irr.
-
irr
public static double irr(double[] values, double guess) Calculates IRR in two stages. First, plain Newton-Raphson from the guess; for compatibility this is exactly the historical algorithm, so every cash flow it already solved keeps its bit-identical result. If it fails to converge (as in bug #64137, where the iteration overshoots to a rate just above -100% and cannot recover) or converges to a meaningless rate at or below -100%, the method falls back to a bracketed Newton-Raphson (the classic "rtsafe" safeguard): the NPV function is bracketed between two rates of opposite NPV sign, then Newton-Raphson steps are taken as long as they stay inside the bracket and converge fast enough, with bisection otherwise. The fallback cannot diverge and cannot return a rate at or below -100%.- Parameters:
values- the income values.guess- the initial guess of irr.- Returns:
- the irr value. The method returns
Double.NaNif no rate with zero NPV could be found - See Also:
-