Compound interest after inflation linked drawings

Viewed 42

Geometric gradient/series problem

Stuck at figuring out a formula/common ratio for the following

Amount = A
draw = d
int = i
inf = f
term = n

YeBal1 = A( 1 + i)^1 - d(1 + f)^1
YeBal2 = (A( 1 + i)^1 - d(1 + f)^1) * (1 + i)) - d(1 + f)^2
YeBal3 = [(A( 1 + i)^2 - d(1 + f)^2) * (1 + i)) - d(1 + f)^2] * (1 + i) - d(1 + f)^3

Every following year YeBal of the previous year becomes the Amount after subtracting d(1 + f)^n. This is where I get lost. If d was constant it is a simple problem.

YeBal1 = A( 1 + i)^1 - d(1 + f)^1

YeBal2 = YeBal(1 + i) - d(1 + f)^2

YeBal3 = YeBal2(1 + i) - d(1 + f)^3

. . . The above is very easy to solve it in Excel. It would be very useful to have a formula for a python app.

1 Answers

I don't exactly get the formula, but the problem seems to be a fit for recursion.
The code might look like this:

def YeBal(year):
    if year == 1:
        return (A*( 1 + i)**1 - d*(1 + f)**1) # YeBal for 1 year
    else:
        return YeBal(year-1)*(1 + i) - d*(1 + f)**year
        # Finds the YeBal for last year and multiplies it acc. to the formula

Note: As already mentioned, I don't exactly get the formula so you might need to make some changes. Like accepting the value of all other variables as well.

Related