0
$\begingroup$

So this is a pension framework. I am trying to code a system and I don't want to have to brute force this answer, but I can't figure out a clean solution. Essentially, I am calculating the total fund value at the time of retirement, given the following:

$$Fund = \sum_{i=1}^t [\cfrac{I\cdot e^{\frac{\pi i}{12K}}}{12K} \cdot C \cdot e^{\frac{Ri}{12K}}]$$

$I = $, annual income, $K = $ pay periods per month, $C =$ Contribution Rate (%), $R =$ expected annualized return (continuous), $\pi =$ expected annual income growth (continuous), $t = $ pay periods until retirement

Solving for the derivatives:

$$ \cfrac{dFund}{dC} = \sum_{i=1}^t [\cfrac{I\cdot e^{\frac{\pi i}{12K}}}{12K} \ \cdot e^{\frac{Ri}{12K}}]$$

$$\cfrac{dFund}{dR} = \sum_{i=1}^t [\cfrac{I\cdot e^{\frac{\pi i}{12K}}}{12K} \cdot C \cdot e^{\frac{Ri}{12K}} \cdot \frac{i}{12K}]$$

If $\Delta Fund_{C} = \Delta C \cdot \cfrac{dFund}{dC}$

How do I solve for $\Delta R$ if I want $\Delta R \cdot \cfrac{dFund}{dR} = \Delta Fund_{C} = \Delta C \cdot \cfrac{dFund}{dC}$?

Basically, is there a way to extract the value of the $\cfrac{i}{12K}$ term within the summation so that it can be expressed outside the summation?

Basically, I want to compute it as:

$$\cfrac{dFund}{dR} = C \cdot \Sigma(\frac{i}{12K}) \cdot \sum_{i=1}^t [\cfrac{I\cdot e^{\frac{\pi i}{12K}}}{12K} \cdot e^{\frac{Ri}{12K}}] = C \cdot \Sigma (\frac{i}{12K}) \cdot \frac{dFund}{dC}$$

The goal is that by doing so, the problem would easily simplify to

$$\Delta R \cdot C \cdot \Sigma (\frac{i}{12K}) \cdot \frac{dFund}{dC} = \Delta Fund_C$$

or, using substitution and rearranging,

$$\Delta R = \Delta C \cdot [C \cdot \Sigma (\frac{i}{12K})]^{-1}$$

which would be a much cleaner solution.

Currently I'm using my code to calculate $\Delta Fund_R$ for a large sequence of $\Delta R$ values and then matching the closest $\Delta Fund_R$ to $\Delta Fund_C$. Incredibly inefficient from a resource standpoint.

Is this mathematically possible?

  • 0
    So it looks like you have $$ \frac{dF}{dR} = C\cdot I\cdot\frac{1}{(12K)^2}\sum_{i=0}^ti\mathrm{e}^{\frac{\pi + R}{12K}i} $$ Can you confirm this? since some of your notation does not make sense.2017-01-27
  • 0
    Apologies, I did not combine like terms to denote different sources of change. But yes, this looks correct.2017-01-27
  • 0
    It seems you start with some exact problem and then try some approximative solution. Could you please first clarify the exact problem? Is it the first sum because $t$ is large? So how large is it?2017-01-27
  • 0
    Yes, if the first equation for $Fund$ is defined with known variables, given either a $\Delta C$ OR a $\Delta R$, is there a way to numerically calculate the other $\Delta$ such that $\Delta Fund$ is equal for both?2017-01-27

2 Answers 2

0

If you are happy with the following $$ \text{Fund} = F = \frac{C\cdot I}{12K}\sum_{i=1}^t\mathrm{e}^{\lambda i} $$ where $\lambda =\frac{\pi + R}{12K}$ and also assuming that $i\in \mathbb{N}$

Then an analytical solution for sum is given by the geometric series $$ \sum_{i=0}^na^i = \frac{1-a^{n+1}}{1-a} = 1 + \sum_{i=1}^na^i $$ so setting $a = \mathrm{e}^\lambda$ and requiring $|a|< 1$ we have $$ F = \frac{C\cdot I}{12K}\sum_{i=1}^t\mathrm{e}^{\lambda i} = \frac{C\cdot I}{12K}\left[-1+\sum_{i=0}^t\mathrm{e}^{\lambda i} \right] = \frac{C\cdot I}{12K}\left[-1 + \frac{1-\mathrm{e}^{\lambda(t+1)}}{1-\mathrm{e}^\lambda}\right] $$ or $$ F = \frac{C\cdot I\cdot \mathrm{e}^{\frac{\pi + R}{12K}}}{12K}\frac{1-\mathrm{e}^{\frac{\pi + R}{12K}t}}{1-\mathrm{e}^{\frac{\pi + R}{12K}}} $$ take derivatives of this and compare with the numerical result (I guess).

$$ \frac{dF}{dR} = \frac{d}{dR}\frac{C\cdot I}{12K}\left[-1 + \frac{1-\mathrm{e}^{\lambda(t+1)}}{1-\mathrm{e}^\lambda}\right] = \frac{C\cdot I}{12K}\frac{d}{dR}\frac{1-\mathrm{e}^{\lambda(t+1)}}{1-\mathrm{e}^\lambda} = \frac{C\cdot I}{12K}\left[-(t+1)\lambda ' \mathrm{e}^{\lambda(t+1)} - \frac{1-\mathrm{e}^{\lambda(t+1)}}{\left(1-\mathrm{e}^\lambda\right)^2}\left(-\mathrm{e}^\lambda \lambda '\right)\right] $$ this leads to $$ \frac{dF}{dR} = \frac{C\cdot I}{12K}\left[\left[-(t+1) -\frac{\mathrm{e}^\lambda}{\left(1-\mathrm{e}^\lambda\right)^2}\right]\mathrm{e}^{\lambda(t+1)} +\frac{1}{\left(1-\mathrm{e}^\lambda\right)^2}\mathrm{e}^\lambda \right]\lambda' $$ this becomes $$ \frac{dF}{dR} = \frac{C\cdot I}{12K}\cdot \frac{\mathrm{e}^\lambda}{\left(1-\mathrm{e}^\lambda\right)^2} \left[1 - \left[(t+1)\left(1-\mathrm{e}^\lambda\right)^2+\mathrm{e}^\lambda\right]\mathrm{e}^{\lambda t} \right]\lambda' $$ Note that we require $|a| = \mathrm{e}^\lambda < 1$ thus $$ \lim_{t\to\infty}\mathrm{e}^{\lambda t}\to 0 $$ therefore $$ \lim_{t\to\infty}\frac{dF}{dR} = \frac{CI}{12K}\frac{\mathrm{e}^\lambda}{\left(1-\mathrm{e}^\lambda\right)^2}\lambda' > 0 $$

  • 0
    This is incredibly helpful, I derived the solution and will post below. Could you please proofread for errors?2017-01-27
  • 0
    ok great - Let me know how it goes and I will be more than happy to take a look.2017-01-27
  • 0
    i just posted it below.2017-01-27
  • 0
    I know there's a mistake somewhere. I just can't find it. If you could proofread, it'd be much appreciated.2017-01-28
  • 0
    @milkmotel updated the answer to show the derivative and how it tends to a positive limit.2017-01-28
0

Using the same notation as Chinny84, starting with

$$ \lambda = \frac{\pi + R}{12K}$$

$$ F = \frac{CI}{12K} \cdot (\frac{1-e^{\lambda (t+1)}}{1-e^\lambda} -1)$$

$$ F = \frac{CI}{12K} \cdot (\frac{e^\lambda -e^{\lambda (t+1)}}{1-e^\lambda})$$

$$ F = (CI)(e^\lambda - e^{\lambda (t+1)}) \cdot (12K)^{-1}(1-e^\lambda)^{-1} = \\ \left[(CIe^\lambda)(12K-12Ke^\lambda)^{-1}\right] - \left[(CIe^{\lambda (t+1)})(12K-12Ke^\lambda)^{-1}\right]$$

$$\frac{dF}{dC} = \left[(Ie^\lambda)(12K-12Ke^\lambda)^{-1}\right] - \left[(Ie^{\lambda(t+1)})(12K-12Ke^\lambda)^{-1}\right]$$

$$\frac{de^\lambda}{dR} = \frac{1}{12K}e^\lambda$$

$$\frac{dF}{dR} = \left\{\left[(CIe^\lambda)(-1)(12K-12Ke^\lambda)^{-2}(-e^\lambda)\right] + \left[(\frac{1}{12K})(CIe^\lambda)(12K-12Ke^\lambda)^{-1}\right]\right\} - \left\{\left[(CIe^{\lambda(t+1)})(-1)(12K-12Ke^\lambda)^{-2}(-e^\lambda)\right] + \left[(\frac{t+1}{12K})(CIe^{\lambda(t+1)})(12K-12Ke^\lambda)^{-1}\right]\right\}$$

or, regrouping:

$$\frac{dF}{dR} = \left\{\left[(CIe^\lambda)(-1)(12K-12Ke^\lambda)^{-2}(-e^\lambda)\right] - \left[(CIe^{\lambda(t+1)})(-1)(12K-12Ke^\lambda)^{-2}(-e^\lambda)\right]\right\} + \left\{\left[(\frac{1}{12K})(CIe^\lambda)(12K-12Ke^\lambda)^{-1}\right] - \left[(\frac{t+1}{12K})(CIe^{\lambda(t+1)})(12K-12Ke^\lambda)^{-1}\right]\right\}$$

Substituting and canceling the negatives,

$$ \frac{dF}{dR} = \left[(C)(12K-12Ke^\lambda)^{-1}(e^\lambda)\right]\frac{dF}{dC} + (\frac{-Ct}{12K})\frac{dF}{dC} \\ = C\left[\frac{-t}{12K} +(12K-12Ke^\lambda)^{-1}(e^\lambda)\right]\frac{dF}{dC}$$

There's a mistake somewhere, as I'm getting a negative $\cfrac{dF}{dR}$. If someone could proofread and find it, that would be much appreciated. I've checked over twice and can't find it.