The concept of Simple Interest is one of the first things anyone learns in Financial Mathematics.
It isn’t really hard to program.
The formula I am using is given below:
Simple Interest Formula
The code to program this is shown below:
# Print out the purpose of the program
print("This program computes the compound amount using simple interest")
print("Reference: An Undergraduate Introduction to Financial Mathematics (Page 2)\n")
# Ask the user for the initial deposit
principal = float(input("Please enter the initial deposit: "))
# Ask the user for the rate as a percentage
rate = float(input("Please enter the rate: "))
# Ask the user for the number of years
years = float(input("Please enter the number of years: "))
# Compute the compounded amount
rate = rate / 100
compounded_amount = principal * ((1 + rate)**years)
print("\nThe compounded amount is:", round(compounded_amount, 2))
When I was in University, most likely 1st or 2nd year, I wanted to participate in the First Bank annual undergraduate essay competition.
The theme for that year was privatization. It was the Atiku days of privatization.
I had read quite a lot on privatization even before the essay. I got more books and started writing. It was flowing and I was looking forward to a good submission.
Until one day, one of my dad’s friends showed up. He asked what I was busy with?
With great enthusiasm, I told him about the competition.
He laughed and said that such competitions from banks are targeted at Finance and Economics undergraduates.
I was studying for a BSc in Mathematics in Ife. He discouraged me totally. I immediately stopped writing.
Fast forward a few months later, the winners were announced.
The top prize winner was an Engineering undergraduate.
I almost became depressed.
But it taught me a great lesson about negative people. I stopped listening to people who say it is not possible.
It was later I realized that the same man was the reason my dad bought a black/white TV in those days and not a Colour TV.
Reason? He said Colour TVs spoil often.
He also discouraged him from buying land in the early 80s because of Omo Onile (Local Gangsters).
Such people exist everywhere around you.
Once you spot them, run!
There will always be good counsellors who will give you great advice.
You will know if you can calm down.
Again, run from negative people who never see good in anything. They will cost you.
I live in Lagos, Nigeria the poverty capital of the world.
This year, I decided to study Financial Mathematics.
I am an Engineer with a BSc in Systems Engineering from the University of Lagos.
My decision to study Financial Mathematics stems from the knowledge that to solve a problem, I must thoroughly understand it.
Programming with Python
Whilst reading the book An Undergraduate Introduction to Financial Mathematics I realized that the formulas where jumping over my head.
Besides, its been a long time since I have done any Mathematics.
So I decided to write the compounding formula as a program. You can find the program below:
# Print out the purpose of the program
print("This program computes the compound amount using monthly compounding")
print("Reference: An Undergraduate Introduction to Financial Mathematics (Page 3)\n")
# Ask the user for the principal amount
principal = float(input("Please enter the principal amount: "))
# Ask the user for the rate as a percentage
rate = float(input("Please enter the rate: "))
# Ask the user for the number of years as a decimal value
years = float(input("Please enter the number of years as a decimal value: "))
# Compute the compound amount (Page 3)
r_n = rate / (12 * 100)
nt = years * 12
factor = (1 + r_n) ** nt
compound_amount = principal * factor
print("\nThe compound amount is:", round(compound_amount, 2))
In doing so, I have a ready made program that I can use to solve the exercises in the book without having to use a calculator.
Conclusion
The essence of code is to replace human rigour and tedium.
In creating this program, I had to study the formula and come up with my own program.