Calculating Inflation, retirement and cost of living adjustmentsover 30 years

Discussion in 'Python' started by rbt, Jun 1, 2005.

  1. rbt

    rbt Guest

    Is this mathematically correct?


    def inflation():
    start = int(str.strip(raw_input("How much money do you need each
    month at the start of retirement: ")))
    inflation = float(str.strip(raw_input("What will inflation average
    over the next 30 years(.03, .04, etc): ")))

    for x in xrange(30):
    start = start*inflation+start
    print start

    inflation()
     
    rbt, Jun 1, 2005
    #1
    1. Advertising

  2. rbt

    John Machin Guest

    rbt wrote:
    > Is this mathematically correct?
    >
    >
    > def inflation():
    > start = int(str.strip(raw_input("How much money do you need each
    > month at the start of retirement: ")))
    > inflation = float(str.strip(raw_input("What will inflation average
    > over the next 30 years(.03, .04, etc): ")))
    >
    > for x in xrange(30):
    > start = start*inflation+start
    > print start
    >
    > inflation()


    The *arithmetic* is tedious but "correct" -- we won't concern ourselves
    with rounding errors here. The *mathematics* might be better expressed as

    required = start * (1.0 + inflation_rate_per_period) ** number_of_periods
     
    John Machin, Jun 1, 2005
    #2
    1. Advertising

  3. rbt wrote:
    > Is this mathematically correct?
    >
    >
    > def inflation():
    > start = int(str.strip(raw_input("How much money do you need each
    > month at the start of retirement: ")))
    > inflation = float(str.strip(raw_input("What will inflation average
    > over the next 30 years(.03, .04, etc): ")))
    >
    > for x in xrange(30):
    > start = start*inflation+start
    > print start
    >
    > inflation()


    I'm not really familiar with financial calculations, but it looks
    correct. There's a faster way though, since repeated multiplication is
    the same as taking the power with the number of years as the exponent:

    def inflation():
    start = ... # same as before
    inflation = ... # same as before

    print start * (1+inflation)**30


    --
    If I have been able to see further, it was only because I stood
    on the shoulders of giants. -- Isaac Newton

    Roel Schroeven
     
    Roel Schroeven, Jun 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Whitecrest
    Replies:
    0
    Views:
    368
    Whitecrest
    Jul 10, 2003
  2. Replies:
    4
    Views:
    414
    Guillaume
    Nov 20, 2005
  3. David A. Black

    "Readability" inflation

    David A. Black, Oct 28, 2005, in forum: Ruby
    Replies:
    68
    Views:
    544
    James Edward Gray II
    Nov 1, 2005
  4. Replies:
    1
    Views:
    136
  5. Howard Martin

    Calculating shipping cost in a form

    Howard Martin, Jul 19, 2005, in forum: Javascript
    Replies:
    10
    Views:
    249
    Lasse Reichstein Nielsen
    Jul 21, 2005
Loading...

Share This Page