473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calculating Inflation, retirement and cost of living adjustmentsover 30 years

rbt
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()
Jul 19 '05 #1
2 2253
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
Jul 19 '05 #2
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
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the...
7
by: JLM | last post by:
I have a table that has fieldA, fieldB, fieldC. I want fieldC=fieldA-fieldB. simple enough. the next record I want to be able to do the same on the new value of fieldC. I can do this with SAP...
0
by: Crimsonwingz | last post by:
I have a database that I wrote to show how much you will have in savings based on some given information: current balance current wage cost of living percent of salary to contribute per month...
3
by: Ron Vecchi | last post by:
I need to calculate the age of a person based on a DateTime BirthDate I was thinking TimeSpan ts = DateTime.Now - BirthDate; //I can get the days but not years. // I could check each...
33
by: potassium flower | last post by:
I am trying to create a food order system for a restaurant. I have tried using both the DSum and Sum functions to calculate the total cost of an order. The total cost is a textbox on the form...
1
by: Dineo | last post by:
Hi there I've created a database and a pivot table but I need to calculates percentages of all the WithdrwalAmt (the amount being withdrawn when retire) per PayeeName (where the money was invested...
1
by: karimufeed | last post by:
I am working on an access project for pension calculation. I want to generate the retirement date automatically at the age of 60 years while filling the date of Birth. i.e. if the Date of birth is...
2
by: bossenb6 | last post by:
I have an assignment to calculate depreciation using straight line, double declining balance and sum of the years digits. Heres what I have so far, but I can't seem to figure it out. Please help!! ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.