Find $R$ in $ B = \sum_{i=1}^{60}P_i\left(1+R\right)^{60-i} $ given $B$ and $P_1, P_2, ..., P_{60}$

41 Views Asked by At

I don't have much training in financial math and was unsure of where to start tackling the following...

Given a series of payments $P_1, P_2, ..., P_{60}$ which are increasing sporadically from one period to the next, is it possible to solve the following equation for some rate of return $R$ discretely, given a fixed amount $B$:

$$ B = \sum_{i=1}^{60}P_i\left(1+R\right)^{60-i} $$

So far I've considered writing out the sum, which results in a nasty polynomial. Is there some clean way to solve for $R$?

Question part II:

If there is no way to solve discretely, what is the most efficient way to estimate an $R$ that results in the sum being within some small error of $B$?

If its helpful with regards to considering efficiency, I'd like to solve the above equation in JavaScript in as little time as possible.

1

There are 1 best solutions below

0
On BEST ANSWER

I ended up going for numerical approximation using the secant method which is basically defining

$$ f(R) = \sum_{i=1}^{60}P_i\left(1+R\right)^{60-i} - B $$

setting $f(R) = 0$ and finding the zero of the function within a given initial range.

For kicks, here is the javascript implementation:

// Find zero of f(x) between x_0 and x_1
function secant_method(x_0, x_1, f, e) {
    // Starting points
    var y_0 = f(x_0), y_1 = f(x_1);
    // Count to prevent infinite loop, default error of 10e-6
    var x, y, count = 1, e = (e || 0.00001);
    // Continue until within error
    while (!(e > Math.abs(y_1-y_0)) && (count++ < 1000)) {
        x   = x_1 - (x_1 - x_0)*y_1/(y_1 - y_0);
        y   = f(x);
        x_0 = x_1;
        x_1 = x;
        y_0 = y_1;
        y_1 = y;
    }
    return x
}