Skip to content
All library documents

Choosing Numerical Methods for Internal Rate of Return

Article Quant Q&A · Author: Jamie1596

Summary

The document discusses how to find an asset’s internal rate of return by solving for the zero of its net present value function. The questioner uses Newton–Raphson first, then switches to interval bisection when Newton–Raphson fails, since difficult function shapes such as asymptotes can prevent convergence. Replies suggest Brent’s method as a robust alternative and describe one contributor’s experience implementing several methods, with Halley’s method performing best in that contributor’s Python case.

The mathematical rationale offered for Halley’s method is that the NPV function is polynomial and its second derivative can be used to achieve cubic convergence, compared with Newton–Raphson’s generally quadratic convergence. Other replies mention secant-based approaches but provide no comparative benchmarks or detailed conditions for choosing among methods. The claims are implementation-specific, and the document does not establish that one algorithm is fastest for all cash-flow patterns or explain how to handle multiple or absent IRRs.

Key ideas

  • IRR calculation can be framed as finding a root of the net present value function.\nNewton–Raphson may converge quickly but can fail for some function shapes or starting conditions.\nBrent’s method is proposed as an alternative that combines root-finding robustness with efficiency.\nHalley’s method uses second-derivative information and is described as having cubic convergence.\nThe reported preference for Halley’s method comes from one implementation and is not a general benchmark.

Tags

Full text
# What is the Most Efficient Way to Calculate the Internal Rate of Return IRR?


# What is the Most Efficient Way to Calculate the Internal Rate of Return IRR?












I have built a program that prices financial assets and it does this in part by calculating the IRR. The problem is that it does not run as quickly as I would like it to.

I currently use the Newton-Raphson method of calculating roots of equations, but then switch to the Interval Bisection method after a set number of tries. This is because there is a chance that the Newton-Raphson method cannot find the IRR, for instance, due to asymptotes. My understanding is that the Newton-Raphson method is more efficient for the cases that it actually works with, which is why my system is currently set up like this.

Is there a more efficient formula or algorithm that I can use to calculate the IRR of a financial asset than the ones that I am currently employing? Or, if there is none, is there a way I can change my current order of calculations to make it more efficient?

If you are in need of any of the formulas that I use to actually be written in this question, please let me know. Thank you for your time.

Update

The pricing software that I have designed is a PHP extension written in the C language. This is because it is a web based program. I cannot change languages due to reasons to do with the company that I work for, so, despite them being good suggestions, I cannot use PERL or the Excel IRR function. I didn't mention the languages before as I didn't think that they were too important due to the fact that I am looking for an increase in mathematical efficiency, not computational.

## Answer by experquisite (score 2, accepted)

https://quant.stackexchange.com/a/12921

You could try Brent's method, it works well.

## Answer by hilbert_spacer (score 1)

https://quant.stackexchange.com/a/41612

I've worked with calculating an IRR for a couple of weeks now. I have implemented 5 different methods and have come to the conclusion that Halley's Method is the most efficient (in my case, using Python) thus far. Brent's method works pretty well too!

Denote the Net Present value function as $P(r)$. We know that finding the IRR requires finding $r_{*} \in \mathbb{R}$ such that $P(r_{*}) = 0$.

Since $P(r)$ is a polynomial, we can take advantage of utilizing the second derivative. According to Wikipedia, we obtain cubic convergence as opposed to Newton-Raphson's quadratic (in general) convergence.

## Answer by Bill (score 0)

https://quant.stackexchange.com/a/12912

No reputation for comments (sorry). What programming language / libraries are you using?

I think that the Excel library just does 20 iterations.

You might find it useful to look at the Perl module Finance::Math::IRR That particular library uses a secant method. The Gnumeric gnumeric.org apparently uses Newton's.

There is a very short paper by Moten & Thron that offers an improvment to the secant method that they claim is more efficient.

## Answer by Durga (score 0)

https://quant.stackexchange.com/a/57906

By mixing multiple approaches I came up with algorithm that does not need guess as an input. I focused on custom precision and resiliency. Please take a look.

https://medium.com/@manchikanti/irr-internal-rate-of-return-calculator-15ec269bd8f5?source=friends_link&sk=21cc51cc485647cb73eb0a66c57522bd

https://chitbazaar.github.io/kautilya/

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.