Saturday, August 20, 2016

Internal Rate of Return and Polynomials

Internal Rate of Return and Polynomials 

The internal rate of return function (IRR) is featured on many financial calcualtors, such as the HP 12C and HP 10bII (Plus) from Hewlett Packard, and BA II Plus (Professional) from Texas Instruments.  It calculates an interest rate of a group of cash flows when the net present value (NPV) is zero.  

0 = CF0 + CF1/(1 + r%) + CF2/(1 + r%)^2 + CF3/(1 + r%)^3 + ...

where r% = r/100 and r = IRR. 

The IRR can also aid in finding a root of polynomial.  Let x = 1/(1 + r/100).  Then:

0 = CF0 + CF1*x + CF2*x^2 + CF3*x^3 + ...

In the case, the cash flows are coefficients of the polynomial.  When calculating IRR, enter cash flows (coefficients) in terms of coefficients of increasing powers of x. 

Once r is calculated, then we can calculate for x (the root):

Algebraic operating system (HP 10bII, BA II Plus, and most others):
IRR [ ÷ ] 100 [ + ] 1 [ = ] [1/x] 

Reverse Polish Notation (RPN) system (HP 12C, a setting on the HP 17B II+):
IRR 1 [ % ] 1 [ + ] [1/x]

Things to keep in mind:

1.  This method is for polynomials for real roots only.  If all the roots are complex, this method is a no-go. 
2. Likewise, no complex number coefficients.  
3. The IRR function and algorithm to adjust it to find the root will be a positive root that is closest to zero (not always, but this is the case most of the time).  

A beautiful article by Valentin Albillo covers this topic for the HP 12C calculator and has a program to find all the roots for polynomials: http://www.hpcc.org/datafile/V21N2/V21N2P35.pdf

Let's look at a few examples. For these examples, all results are rounded to four decimal places (FIX 4). 

Using IRR to Find a Root to a Polynomial 

Example 1:  x^2 + 2x - 3 = 0

Enter the cash flows:
CF0 = -3
CF1 = 2
CF2 = 1

If need be, set P/Y = 1 (not necessary for the HP 12C and BA II Plus (Professional))

Compute IRR to get 0.0000

Follow the transformation x = 1/(IRR/100 + 1) and one root of x^2 + 2x - 3 is:

x = 1.0000

To my knowledge, the only calculator that allows for initial guesses is the HP 12C by entering the initial guess, then pressing [RCL], [ g ], [R/S].  

Example 2: 11.2x^4 - 2.1x^3 + 3x^2 - 3.6x - 2 = 0

Set the cash flows as follows:
CF0 = -2
CF1 = -3.6
CF2 = 3
CF3 = -2.1
CF4 = 11.2

Calculating IRR yields 29.7291.  

Transforming to the root for the polynomial will yield the root 0.7708.  

Simple enough, but let's look at the next example. 

Example 3: x^2 + 10x + 24 = 0

The cash flows for this problem would be:

CF0 = 24
CF1 = 10
CF2 = 1

Straight forward so far.  However, calculating IRR will yield an error.  Why?

The IRR function will require that at least one cash flow be the opposite sign, a mix of negative and positive cash flows.  Looking at what we have, all the flows are positive.  We can make the problem more palpable, we can make another substitution x = -t. As a consequence:

x = -t, x^2 = t^2, x^3 = -t^3, x^4 = t^4, and so on.

Our transformed polynomial is now:  t^2 - 10t + 24 = 0.  

The adjusted cash flows are:

CF0 = 24
CF1 = -10
CF2 = 1


This will require an adjustment in transform from IRR to root:

x = -1/(IRR/100 + 1) 

Procedure if the polynomial is going to adjusted by this additional step:

Algebraic operating system (HP 10bII, BA II Plus, and most others):
IRR [ ÷ ] 100 [ + ] 1 [ = ] [1/x] [+/-]

Reverse Polish Notation (RPN) system (HP 12C, a setting on the HP 17B II+):
IRR 1 [ % ] 1 [ + ] [1/x] [CHS]

Now calculate IRR. 

The HP 10b II+ gives -83.3333.   Translating to the root -6.0000. 

The BA II gives -75.000, which translate to the root -4.0000. 

Both are correct. 

The HP 12C gives Error 3.  However, if I entered an initial guess of say, -50, by keying -50 [RCL], [ g ], [R/S] returns -75.0000.   (For the root of -4.0000 after converting IRR to x (see above)). 

Interesting to see how the IRR function can help find a root of polynomials, which the required adjustments. 

Using the Polynomial Solver to Find IRR

Let's go the other way.  Say we have a scientific, even graphing calculator, and we are going to need to find the IRR but we don't have such function?  

Recall:

0 = CF0 + CF1/(1 + r%) + CF2/(1 + r%)^2 + CF3/(1 + r%)^3 + ...

where r% = r/100 and r = IRR. 

The IRR can also aid in finding a root of polynomial.  Let x = 1/(1 + r/100).  Then:

0 = CF0 + CF1*x + CF2*x^2 + CF3*x^3 + ...

Solving x = 1/(1 + r/100) for r yields:  r = 100*(1/x- 1)

In this case (and ideally), pick the root (x) that is positive and the closet to zero. 

Example 4:  Find the IRR for the following cash flows:
CF0 = -5000
CF1 = 1000
CF2 = 2000
CF3 = 3000
CF4 = 5000

The translated polynomial to be solved is:
0 = -5000 + 1000x + 2000x^2 + 3000x^3 + 5000x^4

Using the PolySmlt2 app of the TI-84 Plus CE I get the following roots, rounded to four decimal places:
-0.1238 ± 1.0739i, -1.1179, 0.7655

Substituting x = 0.7655 into r = 100*(1/x- 1) yields an approximate IRR of 30.6336%.  

Running the problem through the financial calculators yield 30.6348%. Using more decimal places of x will get a more precise IRR. 

This is the relationship between IRR and roots of polynomials.  

Eddie

Source: Albillo, Valentin "HP-12C's Serendipitous Solver". Ex-PPC #4747, HPCC #1075, Datafile.  March/April 2002. http://www.hpcc.org/datafile/V21N2/V21N2P35.pdf



This blog is property of Edward Shore, 2016 

No comments:

Post a Comment

How to Rotate Graphs

How to Rotate Graphs Introduction The key is to use parametric equations in our rotation.  Using the rotation angle θ, the rotatio...