Math You Don't Need

If you really like math, check out Math You Don't Need.

Tuesday, January 10, 2012

Budget: Here's how I do it

How do you make a budget that reflects reality? I didn't care about budgeting until my wife and I joined our bank accounts. Before then, I just winged it. It took me a couple of iterations to get to a solution that was both useful and quick. Now it takes me between 5 and 20 minutes each month, and is well worth it. When I started my own business, I was able to determine how much my minimum salary requirements were which helped me see that it was actually feasible (I could have guessed, but that's a lot of risk and having the numbers to back it up is more responsible).

A simple example of a budget is the following: I need $500 for rent, $150 for bills, $100 for long-term expenses, and $300 for food. The problem with most budgets is that they don't reflect reality. How do you determine the numbers? How would you figure out what next month's bills are going to be? To guess the future, look to the past. Bills in November might be drastically different than bills in August (I'm in Texas where this is true), but bills this November will probably be similar to last November. Rent will probably be the same. But what about the expenses that are more variable, or self-directed. Your rent doesn't change each month, but what you eat probably does.

Accounting is the process of looking at what your income and expenses really add up to. Some people dread accounting, because they always spend more than they think they should. In other words they are unrealistic about how much they spend. The only healthy outlook on finances is reality. Accounting shows you that reality, and from that allows you to accurately budget.

Math Time
There isn't really any math in this section, but there are some numbers. If you get lost in the description, just look at the pictures.

I have 5 categories for my accounting and budget: Bills, Entertainment, Food, Gas, and Miscellaneous. Since my wife and I use our debit cards for pretty much everything, and since we have a joint account, I can open up my online bank statement and copy/paste all items for a month into a spreadsheet (I use Open Office which is free, but you can use MS Excel or any other spreadsheet application). Sheet 1 is a summary sheet, and sheet 2-7 contain 6 months of expenses (I create a new document every 6 months to avoid clutter and I also have a document which shows the summaries since I started for longer-term analysis). Below the summaries you can see the budgeting. It shows how much goes into each account, and it is based on averages derived from the accounting data.

When I copy/paste the entries into the spreadsheet, I go through and delete deposits. I also delete certain expenses that don't count as monthly living expenses (we have a separate savings account for human and vehicle repair bills for example). I delete the deposits column and the total column leaving me with Date, Description, and Amount, to which I append Type. I put one letter B, E, F, G,  or M in the Type column for each expense.

Then comes the magic. I highlight the four columns and use the Subtotals functionality. Go to Data > Subtotals, then group by Type and calculate subtotals for Amount.

That's it. I copy the subtotal for each category and paste it into the summary sheet for comparison with other months. Now I have actual data which I can use to make predictions about the future.

Final Answers
My solution isn't the only one, but it's easy, free, and dead useful. It took about three months worth of accounting data for us to really understand what our budget should be, and we revise it every 6 months or when there is a major change like getting a new job or a significant raise.

Something I do to make this information more useful is to have multiple savings accounts and one checking account. Each savings account is for expenses that aren't related to living expenses during a month. I mentioned human and vehicle, but we have four others as well: Mortgage, Yearly expenses, Cookie Jar, and Nest Egg. Mortgage is obvious. Things like car insurance, property taxes, annual membership dues, and yearly vision care expenses come out of Yearly, and each month we put in 1/12 of what that all adds up to. Cookie Jar is where we put unexpected funds like holiday checks or extra money from a month when expenses were low. It also acts as a pressure valve if one month is too high or if we really need to take a vacation. Finally, Nest Egg is a savings account where we try to keep 6 months or so of our monthly budget on hand in case of emergency or no income (a bit of my mom's advice).

This data can be used to help answer questions like "how much do I need to save or take out in student loans so I can quit my job and go back to school?" or "how much can I save each month for that trip I want to take?"

Thursday, November 17, 2011

Retirement: How much to save, when to retire, and how much you'll need

How does retirement work? How much do I need to retire? How much will I have when I retire? How much do I need to put away to retire? Note: I don't cover Social Security benefits in this post. They are significant, though probably not sufficient.

These questions pop into my head relatively frequently, and I've been getting better at being realistic about them (I'm going to retire at 35 and live off of 200,000 every year, bwa-ha-ha-ha!).

First some definitions:

  • Principal will refer to the amount you have in your retirement account on the day you say "screw you guys, I'm going home" for good.
  • When we talk about interest rate, we're referring to a yearly rate of return. If it's 10% on $10, then after a year you'll have $11.
We'll follow a standard retirement plan:
  1. Let's say you start with some retirement savings.
  2. Then each year you add to it. You do this up until you retire.
  3. This savings will be invested, so each year, your savings will make some money.
  4. At the point you retire, you will have your retirement principal saved up.
  5. Each year, you will take out the amount you need to live on for that year. That will cause your retirement account to shrink.
  6. The principal is invested, so each year it will make interest which will cause it to grow.
  7. We want to set it up to last as long as we do. It shouldn't run out before our life does, but it doesn't need to last much longer, now does it (feel free to set r_n to some amount instead of Zero if you do want to have some amount left over for progeny or charity or what have you)?
When I first started thinking about retirement, my plans weren't nearly this sophisticated. My first idea was to have enough money to live off of the interest. While that would be nice, it requires a lot of money and a high, stable interest rate. My next idea came from something I heard somewhere (maybe my Mom, in which case it comes from Suze Orman), and it was that you just need enough to last out your retirement (estimate to the end of your 99th year). Suppose I want 80,000 a year for 30 years (which means retiring on my 70th birthday). Then I would need to have 80,000 * 30 = 2.4 million. Yikes! That's when I came up with the idea laid out above. Make use of interest during the accumulation phase and during the retirement phase, and you only need enough to last until you're dead. This makes for a much more attainable retirement goal.

Math Time
Let's start by defining some variables:
  • P = Retirement Principal. This is the amount that you start retirement with. For the sake of this math, it will be a constant number. When talking about retirement with people, it is common to talk about your principal changing referring to your retirement account balance changing (just FYI).
  • Y = Yearly retirement salary. This is the amount you want to live on each year. Here it will be constant, but you might have more knowledge of how your needs will change over time. If that is the case, write a simulation program.
  • i1 = Interest Rate during the accrual phase.
  • n1 = Number of years until retirement, or number of years you have to build up the principal.
  • i2 = Interest Rate during the retirement phase. This is often lower due to a decreased desire for risk. You can always just work a little more, but if you lose money on your investments during retirement, it can be a bigger problem.
  • n2 = 99 - retirement age. Number of years you will be retired (i.e. until you're playing backgammon with worms).
  • S = retirement savings you currently have saved up.
  • A = Annual amount put into retirement savings.
  • s_0, s_1, s_k, s_n1 = How much we have in savings after 0, 1, k, or n1 years.
  • r_0, r_1, r_k, r_n2 = How much we have in our retirement account after 0, 1, k, or n2 years.
Here's an outline of what we're about to figure out:
  1. First we'll figure out the relationship between Principal, Yearly retirement salary, number of years of retirement, and interest rate during retirement. The relationship between P, Y, n2, and i2, which will be r_n2. Once we know that, we can answer some questions like "if I retire at 65, how much Principal will I need to live off of 80,000 a year (at different interest rates)?" We will be able to answer this question by noting that r_n2, or the amount that we should have in our savings account by 99 years old, is zero. That will let us solve for P.
  2. Then we'll figure out the relationship between Starting Savings, Annual deposits, interest, and number of years to save. The relationship between S, A, i1, and n1, which will be s_n1. This will allow us to answer questions such as "how much will I have after 20 years of saving 10,000 a year?"
  3. Finally, we'll put it all together by noting that the amount we have after our final year of savings is our principal, which is also our starting amount in our retirement account. In other words s_n1 = P = r_0. This will relate all of our values and allow us to create a sort of retirement calculator.
A few more notes before we begin: In so many financial sequences, we deal with a summation of powers of interest rates. You can find this in the prerequisites page as well as the loan amortization page (which is probably more relevant). If you want to follow the math (and if you've read this far, I'm assuming you do), then make sure you understand that. I'll just use it here, as opposed to proving it again.

Time to get down to it! First, we'll try to understand r_k:
  1. Obviously r_0 = P. We start with our retirement principal ... or do we? Perhaps we should be more realistic and say that r_0 = P - Y. We need to live on something for that first year. We'll have r_0 = P - Y. Let's think this through a little more as we go, so that when we say r_n2, when know what n2 should be.
  2. r_1 is the interest on r_0 minus our Yearly retirement salary. r_1 = r_0 (1+i2) - Y = (P - Y)*(1+i2) - Y = P*(1+i2) - Y*(1+i2) - Y. Those of you who have read some of the other posts should see where this is going. Consider what r_1 represents. r_1 is the amount of money we have after one year, and after taking out what we need to live through our second year. So if we were retiring on our 98th birthday, and r_1 = 0, then we have lived through two full years. In this case n2 would be 1.
  3. r_2 should be the interest on r_1 minus Y again. r_2 = (P*(1+i2) - Y*(1+i2) - Y)*(1+i2) - Y = P*(1+i2)^2 - Y*(1+i2)^2 - Y*(1+i2) - Y = P*(1+i2)^2 - Y*(1 + (1+i2) + (1+i2)^2). 
  4. Already we can see that r_k = P*(1+i2)^k - Y*(1 + (1+i2) + (1+i2)^2 + ... + (1+i2)^k). 
  5. The summation of powers of interest rates becomes ((1+i2)^(k+1) - 1)/(1+i2 - 1) = ((1+i2)^(k+1) - 1)/i2.
  6. Putting it all together and looking at year n2, we get r_n2 = P*(1+i2)^n2 - Y*(((1+i2)^(n2+1) - 1)/i2)
  7. We also know that r_n2 should be 0 since we don't want to have to save up more than we need.
  8. r_n2 = 0 = P*(1+i2)^n2 - Y*(((1+i2)^(n2+1) - 1)/i2), so P*(1+i2)^n2 = Y*(((1+i2)^(n2+1) - 1)/i2)
  9. Thus P = Y * ((1+i2)^(n2+1) - 1) / (i2*(1+i2)^n2). We could simply this a little more, but who cares?
Now let's try to understand s_k:
  1. It's a similar story here. s_0 = S. We start with whatever we have already saved up. 
  2. s_1 = s_0*(1+i1) + A. The interest on what we have plus our annual deposit. s_1 = S*(1+i1) + A
  3. s_2 = s_1*(1+i1) + A = (S*(1+i1) + A)*(1+i1) + A = S*(1+i1)^2 + A*(1+i1) + A
  4. s_3 goes the same way as r went, so to keep things to the point, s_3 = S*(1+i1)^3 + A*(1 + (1+i1) + (1+i1)^2)
  5. s_k = S*(1+i1)^k + A*(1 + (1+i1) + ... + (1+i1)^(k-1))
  6. Using our telescoping series trick we get s_n1 = S*(1+i1)^n1 + A*((1+i1)^n1 - 1)/i1
Let's put it all together now:
  1. We know that s_n1 = P, since after n1 years of saving up, we should have our principal amount.
  2. Thus P = Y * ((1+i2)^(n2+1) - 1) / (i2*(1+i2)^n2) = S*(1+i1)^n1 + A*((1+i1)^n1 - 1)/i1

Final Answers
There are many questions that can now be answered.
  • If I want to retire at 70 and make 80,000 a year supposing I can get a 3%, 5%, or 7% interest rate on my retirement account, how much principal do I need? Note: you can put any one of these equations in google and it will give you the answer, so you can play with the numbers all you like.
    • 3%: P = 80000*((1.03)^(99-70+1) - 1)/(.03*(1.03)^(99-70)) = 1,615,076.37. Still steep, but not as steep as 2.4 million!
    • 5%: P = 80000*((1.05)^(99-70+1) - 1)/(.05*(1.05)^(99-70)) = 1,291,285.89. Getting better, but still pretty heavy.
    • 7%: P = 80000*((1.07)^(99-70+1) - 1)/(.07*(1.07)^(99-70)) = 1,062,213.93. Just over a million is not too high to shoot for a lifetime of savings. Let's look at the savings side to see if it is attainable.
  • If I start saving at 30 with plans to retire by 70 and I am starting with 5000 in savings, how much do I need to save each year supposing I can get a 3%, 5%, or 7% interest rate on my savings account? Let's assume I will get the same interest rate on the retirement account that I get on the savings account. First let's do some rearranging to solve for A. A*((1+i1)^n1 - 1)/i1 = P - S*(1+i1)^n1, so A = (P - S*(1+i1)^n1) / (((1+i1)^n1 - 1)/i1)
    • 3%: A = (1615076.37 - 5000*(1.03)^(70-30)) / (((1.03)^(70-30) - 1)/.03) = 21,203.44. That's pretty steep!
    • 5%: A = (1291285.89 - 5000*(1.05)^(70-30)) / (((1.05)^(70-30) - 1)/.05) = 10,398.08. That's starting to seem more attainable for some folks, though probably not folks in their 20's.
    • 7%: A = (1062213.93 - 5000*(1.07)^(70-30)) / (((1.07)^(70-30) - 1)/.07) = 4,945.73. If you can save up 5000 a year and you have 40 years until you retire, and you can find an average annual rate of 7%, then you can live on $80,000 a year for 30 years.
  • Here are some other scenarios:
    • Y=40000, retire at 70, rates of 3%, 5%, and 7%
      • 3%: P = 40000*((1.03)^(99-70+1) - 1)/(.03*(1.03)^(99-70)) = 807,538.18.
      • 5%: P = 40000*((1.05)^(99-70+1) - 1)/(.05*(1.05)^(99-70)) = 645,642.94.
      • 7%: P = 40000*((1.07)^(99-70+1) - 1)/(.07*(1.07)^(99-70)) = 531,106.96. Note that these are all half (they come out exact, but I rounded) of Y=80000. This pattern holds true, so Y=60000 would give you half again as much as 40000.
    • Continuing the above scenario for starting at 30 with 5000 in savings, what is A?
      • 3%: A = (807538.18 - 5000*(1.03)^(70-30)) / (((1.03)^(70-30) - 1)/.03) = 10,493.56. A little less than half (this isn't just rounding error).
      • 5%: A = (645642.94 - 5000*(1.05)^(70-30)) / (((1.05)^(70-30) - 1)/.05) = 5,053.35. 
      • 7%: A = (531106.96 - 5000*(1.07)^(70-30)) / (((1.07)^(70-30) - 1)/.07) = 2,285.34. 
These numbers are a hard truth to face. Luckily, what I have shown you is not the full picture. There are significant advantages to reality. For one, if you are investing monthly, then you will make significantly more on interest. Consider the first month of the year. Instead of that money sitting around for a year, it will be earning interest. It might not seem like much, but it adds up. It is significant. Also, if instead of taking out what you need each year, you do so each month, or bimonthly, or even weekly, then the money you don't take out will continue to earn interest as well. These changes will significantly improve your outlook on retirement. I will add a new post as a continuation of this one detailing those changes once I figure out the math. So don't despair as much, especially if you're still young. I will admit that these numbers caused me to start my own business and join the Austin Real Estate Investment Club. Stay tuned for the truth, and feel free to use google calculator and the equations above to test your own ideas about retirement.

So the math is relatively similar:

  • P = Retirement Principal.
  • M = Monthly salary.
  • i1 = Interest Rate during the accrual phase. We will be working with (1+i1/12)
  • n1 = (Retirement age - current age) * 12. Number of months until retirement.
  • i2 = Interest Rate during the retirement phase.
  • n2 = (99 - retirement age) * 12. Number of months you will be retired.
  • S = retirement savings you currently have saved up.
  • D = Monthly Deposit into retirement savings.
  • s_0, s_1, s_k, s_n1 = How much we have in savings after 0, 1, k, or n1 months.
  • r_0, r_1, r_k, r_n2 = How much we have in our retirement account after 0, 1, k, or n2 months.
We can work through the same sequence math to solve for P:
  1. r_0 = P - M
  2. r_1 = r_0*(1+i2/12) - M = P*(1+i2/12) - M*(1 + (1+i2/12))
  3. r_2 = P*(1+i2/12)^2 - M*(1 + (1+i2/12) + (1+i2/12)^2)
  4. r_n2 = P*(1+i2/12)^n2 - M*((1+i2/12)^(n2+1) - 1)/(i2/12) = 0
  5. P = M*((1+i2/12)^(n2+1) - 1) / ((i2/12)*(1+i2/12)^n2)
And also to solve for D:
  1. s_0 = S
  2. s_1 = s_0*(1+i1/12) + D = S*(1+i1/12) + D
  3. s_2 = S*(1+i1/12)^2 + D(1 + (1+i1/12))
  4. s_n1 = S*(1+i1/12)^n1 + D((1+i1/12)^n1 - 1)/(i1/12) = P
  5. D = (P - S*(1+i1/12)^n1) / (((1+i1/12)^n1 - 1)/(i1/12))

Final Answers (cont.)
Again let's have M = 80000/12 = 6666.67, retiring at 70, and getting 3%, 5%, and 7%:
  • 3%: P = 6666.67*((1+.03/12)^((99-70)*12+1) - 1) / ((.03/12)*(1+.03/12)^((99-70)*12)) = 1,554,916.38
  • 5%: P = 6666.67*((1+.05/12)^((99-70)*12+1) - 1) / ((.05/12)*(1+.05/12)^((99-70)*12)) = 1,230,222.50
  • 7%: P = 6666.67*((1+.07/12)^((99-70)*12+1) - 1) / ((.07/12)*(1+.07/12)^((99-70)*12)) = 998,538.69
Savings to achieve that get's better too:
  • 3%: D = (1554916.38 - 5000*(1+.03/12)^((70-30)*12))) / (((1+.03/12)^((70-30)*12) - 1)/(.03/12)) = 1,661.17 per month or 19,934.04 per year.
  • 5%: D = (1230222.50 - 5000*(1+.05/12)^((70-30)*12))) / (((1+.05/12)^((70-30)*12) - 1)/(.05/12)) = 782.05 per month or 9 384.60 per year. Compared to 10,398.08, that's a pretty huge difference.
  • 7%: D = (998538.69 - 5000*(1+.07/12)^((70-30)*12))) / (((1+.07/12)^((70-30)*12) - 1)/(.07/12)) = 349.35 per month or 4,192.20 per year

Wednesday, November 9, 2011

Health Insurance

Which private health insurance policy is the most cost effective for me? I had to find some private health insurance recently, and so I did some looking around. I learned a good number of definitions, and ended creating a spreadsheet to run different simulations and find the most cost effective plan.

First some definitions:

  • Copay: When you go to the doctor for something routine or when you buy prescription medicine, there is often a copay. It will either be a flat number like $35 or it will be a combination of $30 and 20%. Suppose the medication costs $200. Then you would pay $30, and the $170 left over would be split 80-20 between the insurance company and you. 20% of $170 is $34, so you would be $64 out for this medication.
  • Coinsurance: This is the 20-80 split. Almost all plans will have coinsurance for certain cases such as hospital stays, maternity (although private health insurance plans almost never cover maternity which is lame and a half! or 3*lame/2), and often emergency room visits. I was leaving the safety of UT health insurance which had 0% coinsurance for most stuff including emergency room visits (which was nice when we walked out of there for $100 for a bill that was over $13,000!).
  • Deductible: This is a tricky one, because each plan is different when it comes to what the deductible is applied to. The idea behind the deductible is similar to the copay. After you pay the deductible, the rest is covered, or there's an 80-20 split afterwards. Deductibles for private insurance are usually between $500 and $10,000, but mostly between $1,000 and $5,000. The UT deductible was $350. Pretty nice perks, but it had a much higher premium around 450/month. There is usually a correlation between deductible and premium.
  • Premium: Amount you pay the insurance company each month to maintain the health insurance. This is the monthly cost of the health insurance plan you choose.

Math Time
Well, not so much. The formulas and equations are very useful when there are variables which can be any number (3.4, .0001, 533432.21, etc), but with health insurance plans, there are a few plans which don't have adjustable values. For this type of situation, I prefer to set up scenarios and see how they play out. This requires a lot of realism. If you take the lowest premium, then you'll pay the least ... assuming you never need medical care. That's a big assumption! So the scenarios, which are predictions of the future, must be as realistic as you can make them (often predictions of the future should be based on patterns of the past, but that is a huge topic unto itself).

I looked at a bunch of different health insurance plans online and did some initial filtering to weed out the obvious bad ideas. There are different types of health plans, and I certainly don't understand the different types very well, but I have always had a PPO plan. PPO stands for Preferred Provider Organization. If you want to learn about the nuances and definitions of the different types of plans, start here: I also knew that deductibles of $10,000 were absurd. When I do have something happen, I don't want to be out of pocket by $10,000. That doesn't give me the ability to plan that I desire out of a health insurance plan. If I wanted to pay as little as possible and take a huge hit if anything did happen, I just wouldn't have health insurance (that's the cheapest plan). So how much money was I willing to have sitting around, collecting dust in case of emergency? Less than $3,000. So I only looked at PPO plans with deductibles under $3,000. Now to weed out the ones that only apply for very select hospital where doctor-nobody-recommends-me works. This left me with two different plans that had varying deductibles and premiums and other considerations from Blue Cross Blue Shield (BCBS).

Time to whip out the spreadsheet! I used open office because I didn't have a copy of MS excel, but they're pretty much the same. I calculated the yearly costs of the premiums first for each different plan, just to see what I was looking at paying. I then looked at what a year with a $5,000 medical expense would look like, what one with a $10,000 expense would look like, and what the maximum out of pocket would look like (all plans that I've seen have a maximum out of pocket number which means that you'll never have to pay more than that in a year). Then I took 6 columns and calculated out the two plans with various scenarios for each of their premium and deductible levels. After looking at a riskier one where I would need very little medical care, and a more conservative one where I would need more medical care, I settled on one year out of the next six needing $5,000 worth of medical care, and one year being the max out of pocket out of the six years. Looking at the costs over six years including some medical care showed that the lowest cost plans for me were somewhere in the middle. They didn't have the lowest deductible, but they also didn't have the lowest premium.

Final Answers
After finding out what was likely to be my medical costs over the next 6 years, I divided that number by 72, the number of months in the 6 years, in order to correctly budget for realistic medical bills. Whatever portion of that doesn't go towards the premium goes into a savings account we have set aside for medical expenses. As you can see in the image below, I should be saving 17,356/72 or $241.06 per month with $148 going towards the premium, and $93.06 going into savings. I always prefer a budget that is realistic to one with numbers I made up based on a gut feeling, and if some medical care is needed, I don't have to feel anxious about the financial implications (laughter is the best medicine, not anxiety!). In the screenshot below, you can see the formula for calculating yearly expenses for a year with $10,000 worth of medical care which is the yearly premium plus 20% of (10000 minus the deductible) plus the deductible.

As an aside, they tried to charge me 30% more due to my BMI score (which is around 30, and anyone who knows me realized just how ridiculous the BMI scale is). It took 3 phone calls before someone told me how to appeal it, and a doctors note saying that I wasn't caught in the lethargic grip of obesity, but they did remove that premium hike.


This math blog uses various symbols and requires some understanding of algebra. In this post I will define the symbols and give examples and references for self-study.

First some definitions:

  • The carat symbol, ^, is used for exponents. 3^2 is 3*3 or 9. 2^4 is 2*2*2*2 or 16.
  • Parentheses are used to group terms in order to avoid ambiguity. For example 3^2/4/5-1 is somewhat ambiguous. You could read it as 3^(2/4) / (5-1) or ((3^2) / (4/5)) - 1. You should always treat parentheses as a number. For 3^(6/2), you should first find (6/2) = 3, and then evaluate 3^3 = 3*3*3 = 27.
  • Order of operations: First evaluate from left to right Parentheses and Exponents, then Multiplication and Division, then addition and subtraction. For example, 3^2 - 4*(7-3)^2 / (1/2) can be evaluated in multiple ways, each of which is equally valid. After doing enough evaluations, you develop intuition about which way will be easiest. The term (7-3)^2 jumps out to me. You could either do the subtraction operation inside the parentheses first, or do the squaring first. Doing the subtraction gives us 4^2= 16. That was easy. Doing the squaring gives us (7-3)*(7-3) = 7*7 - 7*3 - 3*7 + 3*3 = 49 - 21 - 21 + 9 = 16. That was a little more difficult! Another point about order of operations is that it makes some parentheses unnecessary. Consider 2^4 - 3/2 + 16^(1/2) / 2. If we were to use parentheses to fully separate each calculation, it would look like (((2^4) - (3/2)) + ((16^(1/2)) / 2)). That's just too much to keep track of. Instead, we can remove the parentheses around 2^4 because order of operations tells us that exponents get applied before subtraction. Also the parentheses around 3/2 can be removed because division happens before subtraction and addition. So order of operations gives you the ability to unambiguously remove parentheses due to tighter and looser groupings (exponents and subtractions respectively).
  • Using letters instead of numbers: It is necessary to use letters instead of numbers in an equation if the goal is to make a general statement. If I tell you that I bought 3 chickens for 5 bucks a piece and spent 15 dollars, that's nice but it doesn't tell you how many chickens you can buy. I have just described the equation 3 * 5 = 15. Let's use letters instead. Let's use P for the price of chickens, N for number of chickens, and C for total cost of purchasing n chickens for P price. We can write this as n * P = C. There are two things you can do with this equation that you couldn't do with the numbers: you can figure out any of the numbers if you know the other two, and if you only know one of them you can create some scenarios using a reasonable range for another of the variables in order to estimate the third, unknown quantity. For example, chickens cost $4.37 today and we need to buy 10 for an event. We can now figure out C, the total cost since we know C = n * P = 10 * 4.37 = 43.70.
  • Algebra is the language of mathematics. If you understand Algebra, then you can not only follow along with all of my calculations, but you can come up with your own. Below I will attempt to build the scaffolding of Algebra, but it takes practice to become proficient. I highly suggest doing the exercises in the Khan Academy links below. They're fun and you'll learn Algebra!

Math Time
Let's start with some Exponent rules:

  • Exponents are really just shorthand for the same thing multiplied together over and over. 3^5 = 3*3*3*3*3. (x+1)^3 = (x+1) * (x+1) * (x+1). Some ideas pop out pretty quickly. What is 1^2? 1*1 = 1. What about 1^5? 1*1*1*1*1 = 1. We can see that 1^n = 1 whenever n is a whole number greater than 0 (i.e. 1, 2, 3, ....). Similarly 0^2 = 0 * 0 = 0. 0^n = 0 under the same conditions on n. Now let's look at negative numbers raised to powers. (-2)^2 = (-2) * (-2) = 4. (-2)^3 = (-2)*(-2)*(-2) = -8. Let's look at how exponents work when we multiply numbers with the same base (the base is the number being raised to the power). 3^2 * 3^3 = 3*3 * 3*3*3 = 3^5. By this same logic, 3^60 * 3^40 = 3^100. Note that 3 = 3^1. The exponent of 1 is assumed if it is not written. For more exponent rules, check out You can also look at the next two videos, exponent rules 2 and 3. If we use symbols instead of numbers we see some general truths come out: a^x * a^y = a^(x+y).
  • Let's talk about fractions and division. A fraction such as 5/3 should be thought of as "how many 3's does 5 have?" If you have trouble thinking about what a 5 or a 3 is, you can think about a 5 gallon bucket and a 3 gallon bucket. How many 3 gallon bucket loads could fit in a 5 gallon bucket? Let's look at some examples:
    • 2/1: How many 1's does 2 have? 2
    • 3/2: How many 2's does 3 have? 3 has one full 2, and half of another 2, so 1.5 or 1 and 1/2 (which is called a mixed number and I'll write it as 1 1/2 from now on)
    • 1/2: How many 2's does 1 have? 1 only contains half of one 2, so 1/2 or .5
    • 3/(1/2): How many 1/2's does 3 have? It takes two halves to make a whole, and 3 is three wholes, so it takes 6 halves to make 3.
    • (1/2)/3: How many 3's does 1/2 have? 1/2 only has 1/6 of a 3.
  • So we can start making some generalizations about fractions. First off, you can't divide by zero, so don't even try! (unless you're in calculus, then go hog wild!) If we look at a fraction, it pretty clearly has a top and a bottom. 5/3 has 5 on top and 3 on bottom. The top is called the numerator and the bottom is called the denominator. The numerator is 5 and the denominator is 3 in the example above. There is an indispensable property to know which is called multiplying by the reciprocal. We already saw that 3/(1/2) = 6 and we also know that 3*2 = 6. That property generalizes to (a/b)/(c/d) = (a/b) * (d/c). This is stated as "dividing by a fraction is the same as multiplying by it's reciprocal," or "flip and multiply". If you don't have a solid background in fractions (which is nothing to be ashamed of), then I highly suggest watching the series of Khan Academy fraction videos at
  • I will say a little more about fractions.
    • When you multiply fractions (3/4) * (5/11) you multiply the numerators and denominators. (3*5) / (4*11). If you ever forget a rule like this, try two or three examples. Consider (3/1) * (1/3). Intuitively you know it should be three thirds, or 1. 
    • When you add fractions, you need a similar denominator. Consider 1/2 + 1/3. The easiest way to get a common denominator is to multiply the two denominators that you are trying to add together, 2*3=6. The idea is that you can represent 1/2 as 3/6, and 1/3 as 2/6, so now we have 3/6 + 2/6. Fractions with the same denominator can now be added together. If I have 3 parts of 6 and 2 more parts of 6, then I have 5 parts of 6, or 3/6 + 2/6 = 5/6. Another way you can write this is (3+2)/6. When you have the same denominator, you can combine terms and add the numerators.
    • If you have more complex numerators and denominators such as (4*5 + 1)/(3^2 - 1) they can sometimes be simplified. The art of simplification (it really is an art) comes from intuition which comes from doing it over and over and over again. Practice with the exercise portion of the Khan Academy.
  • Now let's talk about factoring and distributing. Suppose you have 3 * (5+2). You can figure that out by noting that 5+2 = 7, and 3*7 = 21, but you can also distribute the 3 and note that 3*5 + 3*2 = 15 + 6 = 21. 3 * (5+2) = 15 + 6. You can distribute the 3 to each number being added, and you can do the opposite, which is called factoring, and factor out the 3 from 15 and 6. As another example, 27 - 9 = 9 * (3 - 1). You could also factor out a -9, -9 * (-3 + 1). If we start using symbols, we can write x * (a+b) = x*a + x*b. Also consider x^2 + x. That's just x*x + x, so we can factor out an x to get x * (x + 1). We can do this with more than two terms, too. 3*x^4 + 4*x^2 - x = x * (3*x^3 + 4 * x - 1). So far, we have been factoring and distributing one number. What if we have (x + y)^2. We know that is (x+y) * (x+y), but how do we distribute this? In the same way. Treat the left x+y as an atomic thing and you get (x+y)*x + (x+y)*y. We just distributed the quantity (x+y) to the right (x+y). Now if we distribute x in we get x*x + y*x + (x+y)*y. Now distribute the y and we get x*x + y*x + x*y + y*y. Remember that multiplication is commutative (in other words, 3*5 = 5*3, you can switch the numbers around). We can simplify (x+y)^2 = x^2 + 2*x*y + y^2. To show that with numbers, let's use (3+4)^2 = 7^2 = 7*7 = 49. Also, (3+4)^2 = 3^2 + 2*3*4 + 4^2 = 9 + 24 + 16 = 49. To learn a little more about factoring quadratics (going from x^2 +2*x*y + y^2 to (x+y)^2) please watch the Khan Academy videos starting with
If you can work with exponents, fractions, and factoring, then you have most of algebra covered. If you also become proficient with working with variables instead of numbers, then you are ready to tackle anything in this blog and more.

There are two more pieces that come up over and over in the math I have needed over the years, and they are an understanding of sequences and series. First let's talk about sequences:
  • I use the symbol a_0 and a_1, which should be read as a-sub-zero and a-sub-one. Let's look at one of my favorite sequences, the triangular numbers. The first five are 1, 3, 6, 10, and 15. In other words a_1 = 1, a_2 = 3, a_3 = 6, a_4 = 10, and a_5 = 15. You might be able to guess the pattern which is 1, 1+2, 1+2+3, 1+2+3+4, and 1+2+3+4+5. 
  • We could represent a_1 = 1, a_2 = a_1 + 2, a_3 = a_2 + 3, a_4 = a_3 + 4, and a_5 = a_4 + 5. What if we wanted to know a_10? We could add ten numbers together, but that would be a pain, especially when we start asking about a_100 and so on. The general form of any element of the sequence would be a_i = a_(i-1) + i. Read this as a-sub-i equals a-sub-i-minus-one plus i. Here i is a placeholder. If i = 4, we would have a_4 = a_3 + 4 which is what we saw above. But again, this is awful to compute when i is large. This is known as the recursive form of the sequence because it is defined based not just on i, but on previous terms of the sequence which are in turn based on previous terms of the sequence all the way down to the base case of a_1 = 1. If we can find a formula based only on i, that is called the closed form of the sequence, and is way easier to compute for large values of i. 
  • The clever mathematician Gauss figured this out in first grade. He finished his work early, and his annoyed math teacher told him to add up the numbers between 1 and 100 (or rephrased, find the 100th triangular number). After thinking about it for a minute, he spouted out the answer: 5,050! He realized that 1 and 100 added up to 101, 2 and 99 added up to 101, 3 and 98 added up to 101 and so on. There were 50 of these pairs of 101, so he got 50 * 101 = 5050. Pretty clever, huh. So in other words, the closed form of the solution is a_i = (i+1) * i/2. How, in general, do we go from a recursive form of a sequence to closed form? That is a subtle and complex field of mathematics (usually number theory) which is both useful and fun. I studied number theory in college because it was so fun.
Now let's talk about series:
  • When you have to add a bunch of similar things up, you have series. In textbooks you'll see the capital Greek letter, Sigma, which is terrifying to anyone who isn't a mathematician. In everyday math, we don't usually run into infinite sums (which is good, 'cause damn!). Instead we are usually dealing with some number of terms. In Loan Amortization, that number is 360. That's a lot of things to add up! When I write a sum in this blog, I will write it as (1 + x + x^2 + ... + x^(n-1)) for example. I find the sigma notation to be relatively obtuse and useless. The series should have enough terms to make it obvious what the ... refers to.
  • Time for some examples: Let's say we have two sums that we are subtracting. (x + x^2 + ... + x^n) - (1 + x + x^2 + ... + x^(n-1)). This is called a telescoping series, because all of the middle terms cancel out and your left with the two ends. So let's actually combine them: x - x + x^2 - x^2 + ... + x^(n-1) - x^(n-1) + x^n - 1. All of the terms cancel out except for the x^n term and the -1 term. We go from something really nasty that would take all day to compute by hand, to two computations. That's pretty sweet!
  • Using the idea of telescoping series as our intuition, we can solve a common series which comes up. Consider the series (1 + x + x^2 + ... + x^(n-1)). If we knew x and n, we could figure out the number that this sum added up to. Let's call that number S. We know from above how we could create a compact solution if we had another similar series, so let's state that a little more exactly. (x + x^2 + ... + x^n) - (1 + x + x^2 + ... + x^(n-1)) = x^n - 1. We know that the second series is S, and the first one looks just like S, but with all of the terms multiplied by x. If we factor out that x, then we get x*(1 + x + x^2 + ... + x^(n-1)) which is just x * S. Let's write it out now: x * S - S = (x + x^2 + ... + x^n) - (1 + x + x^2 + ... + x^(n-1)) = x^n - 1. Well, we can factor an S out of x*S - S to get S(x-1). If we now solve for S, we get S = (x^n - 1) / (x-1). So (1 + x + x^2 + ... + x^(n-1)) = (x^n - 1) / (x-1). I didn't believe it at first either. How could it be so nice looking! A surprising number of thing sin mathematics are very elegant, indeed.

Final Answers
Math is fun! If you want more help on this material, I highly suggest working through the practice problems on the Khan Academy website. They are both fun and educational, and they fill in the gaps. Math is very much built up one concept on top of another, so if you have gaps, it really impedes your ability to understand anything above those gaps. I am a huge fan of the Khan Academy website because it really tries to fill in those gaps.

Also, as always, feel free to comment with questions and I will answer them!

Tuesday, November 8, 2011

Loan Amortization

How does Loan Amortization work?! Am I getting screwed?! In short, it depends. It's actually quite reasonable (though the math is a little tricky) if you are planning on paying the loan off over the lifetime of the loan. If instead you are planning on paying it off for a little while, and then cashing out (selling the house) ... well, that's not so nice since you will have paid mostly interest and your equity will still be rather small.

First some definitions:

  • Loan Amortization: When you take out a mortgage, you sign a contract agreeing to pay back the amount over some number of years (usually 15 or 30) with interest. Amortization is the act of divvying up those payments so that at the end of your payback period (those 15 or 30 years), you have fully paid back the amount you were loaned (with interest, of course).
  • Monthly payment: Each month, you pay the interest that has accrued over the last month plus a little principal. As you will see in the math below, the amount of principal you pay back changes each month (it becomes more and more of your monthly payment). The monthly payment is a set dollar amount (this is to help people budget), but as you pay off more and more of the principal, there is less and less interest that accrues each month, so the part of the monthly payment that goes towards principal grows over time.
  • Equity: The amount you have paid that didn't go toward interest. When you sell the house, you get this plus (or minus) any appreciation that has occurred.
  • Amortization Schedule: A tabular breakdown of how much interest and principal you pay for each month of the mortgage.

Math Time
Let's start by defining some variables:
  • M = monthly payment
  • A = loan amount
  • r = 1 + (yearly interest rate / 12) ... this is 1 + the monthly interest rate
  • a_0, a_1, a_i, and a_n all refer to how much principal is left to pay after some number of months
  • n = number of months to pay back the loan
  1. How much principal is left at the very beginning after no time has passed? All of it! In other words, a_0 = A.
  2. After one month has passed (a_1), how much principal is left? After one month, you have made one of your monthly payments. It includes some interest, and some principal. A*r is the total amount plus the first month's worth of interest on the total amount. So A*r - M is the total amount plus the first months worth of interest, minus the first months worth of interest and the first months worth of principal. Obviously the interest cancels out, and you have A*r - M is the amount of principal left after the first months principal is subtracted off. Now notice how I haven't really said what M is. That's because our goal is to figure out M given A, r, and n. What we're going to do is use the knowledge that a_n should be 0, or after n months the loan should be paid off. So to recap, a_1 = the amount of principal left after one month = A*r - M. Notice that a_0 = A so we could write a_1 = a_0 * r - M.
  3. Let's consider a_2. Remember that a_2 means the amount of principal left after two months. By the same logic as above, that would be the current amount of principal we have left plus the interest for this month minus the interest for this month and the principal for this month. a_2 = a_1 * r - M. If we expand this we get a_2 = (A*r - M) * r - M = A*r^2 - M*r - M.
  4. We can see that a_i = a_(i-1) * r - M, so a_i = A*r^i - M*r^(i-1) - ... - M*r - M. Let's factor a -M out of the terms that have it: a_i = A*r^i - M(r^(i-1) + r^(i-2) + ... + r + 1).
  5. Now we know that a_n = 0 since after n months are up, we have paid off the loan so the principal left is Zero (woohoo!). a_n = 0 = A*r^n - M(r^(n-1) + ... + r + 1). With a little algebra we get M = (A*r^n) / (r^(n-1) + ... + 1).
  6. The numerator looks easy enough, but if we're dealing with a 30 year mortgage, that's 360 months, so 360 terms to add up in the denominator! Lame. Luckily there's a clever as heck way to simplify the denominator using a telescoping series trick. That gives us M = (A*r^n) / ((r^n - 1) / (r - 1)). Since we have a fraction in the denominator, we can multiply by the reciprocal (this is basic algebra), and get M = (A*r^n * (r-1)) / (r^n - 1).
  7. The banks will tell you what interest rate you qualify for, so we know r. There aren't that many types of conventional loans you can get, so you can run scenarios for each loan type (15 year, 30 year, ARMs, etc) which gives you n. Finally you probably have some idea of what monthly payment you can afford so you know what M should be. Now from all of that, you can figure out A: what house price you can afford. This is a little contrived, since there are also closing costs, a downpayment, taxes and insurance (which are pretty heavy), initial repairs, inspections, and potentially other costs as well as tax breaks.

Final Answers
Using basic algebra we get:
  • M = (A*r^n * (r-1)) / (r^n - 1)
  • A = M(r^n-1) / ((r-1) * r^n)
  • r and n ... bah! (comment if you can figure them out, I don't feel like it and those probably aren't questions you need answered)
Let's look at an example ... how about my mortgage.
I bought a house for $229,000 and put 20% down so my mortgage was for $183,200. It was for a term of 30 years, or 360 months at an interest rate of 4.5%.
Thus M = (183200 * (1+(.045/12))^360 * (1 + (.045/12) - 1)) / ((1+(.045/12))^360 - 1) = 183200 * 1.00375^360 * .00375 / (1.00375^360 - 1) = $928.25.
Note that if I paid that amount for 360 months, I would be paying $334,170 for a total amount of 82.4% or $150,970 in interest paid. That might seem like a staggering amount, however house values tend to appreciate over time (national averages are usually stated around the inflation rate of 3-5% per year). So if my house appreciates by 3% per year, then based on the math in Savings Account, my house will be worth 229000*(1.03)^30 = $555,843.11, for a total appreciation of 142.7% or $326,843.11. Again this is contrived since it doesn't take into account the multitude of situation that can occur in 30 years, but just looking at interest, things don't look so bad and house purchasing as opposed to renting can become financially sound.

What I haven't mentioned is how boned you are if you turn around and sell your house. For that we will need to determine how much of your monthly payments go towards interest and how much go towards principal. We kind of already know the interest part. The interest after the first month is the monthly rate, we'll use R (which is different than the r we used above), times the amount currently owed, or A*R. Since the monthly payment is just the interest plus the principal paid for any given month, M - A*R is the principal paid for the first month. For the second month we have A - (M - A*R) as the principal left so the interest is (A - (M - A*R)*R = (A + A*R - M)*R = A*R + A*R^2 - M*R, and the principal paid is M minus that, or M - A*R - A*R^2 + M*R = M + M*R - A*R - A*R^2. Let's look at the total interest and principal paid so far. The interest is A*R + A*R + A*R^2 - M*R or 2A*R + A*R^2 - M*R. When I start seeing a pattern like this I get a little worried. My intuition tells me I will have a large number of terms to figure out. So I'll just cheat and write a looping python program.

def amnts(loan_amount, yearly_rate, months_paid, monthly_payment):
    monthly_rate = yearly_rate / (12.0 * 100)
    total_int_paid = 0
    total_pr_paid = 0
    interest_paid = 0
    principal_paid = 0
    for i in range(0,months_paid):
        interest_paid = loan_amount * monthly_rate
        principal_paid = monthly_payment - interest_paid
        loan_amount -= principal_paid
        total_int_paid += interest_paid
        total_pr_paid += principal_paid
        print str(i+1) + ': int: ' + str(interest_paid) + ', pr: ' + str(principal_paid)
    print 'total int: ' + str(total_int_paid) + ', total pr: ' + str(total_pr_paid)

Call the function with amnts(183200, 4.5, 24, 928.25)
1: int: 687.0, pr: 241.25
2: int: 686.0953125, pr: 242.1546875
3: int: 685.187232422, pr: 243.062767578
4: int: 684.275747043, pr: 243.974252957
5: int: 683.360843595, pr: 244.889156405
6: int: 682.442509258, pr: 245.807490742
7: int: 681.520731168, pr: 246.729268832
8: int: 680.59549641, pr: 247.65450359
9: int: 679.666792021, pr: 248.583207979
10: int: 678.734604992, pr: 249.515395008
11: int: 677.79892226, pr: 250.45107774
12: int: 676.859730719, pr: 251.390269281
13: int: 675.917017209, pr: 252.332982791
14: int: 674.970768523, pr: 253.279231477
15: int: 674.020971405, pr: 254.229028595
16: int: 673.067612548, pr: 255.182387452
17: int: 672.110678595, pr: 256.139321405
18: int: 671.15015614, pr: 257.09984386
19: int: 670.186031726, pr: 258.063968274
20: int: 669.218291845, pr: 259.031708155
21: int: 668.246922939, pr: 260.003077061
22: int: 667.2719114, pr: 260.9780886
23: int: 666.293243568, pr: 261.956756432
24: int: 665.310905731, pr: 262.939094269
total int: 16231.302434, total pr: 6046.69756598

So I will have paid $22,278.00, of which $6,046.70 will be equity. Now lets look at appreciation on top of this: 229000(1.03)^2 = $242,946.10. So I will actually have $6,046.70 + $13,946.10 = $19,992.8 in equity. Hmm ... I don't feel too boned. The moral here? Someone won't let you make use of a large sum of their money for nothing, so they charge interest on the loan. If you do more than just hold onto it, such as invest it in real estate (which is what you are doing when you buy a house), then you can actually turn a mortgage into a win-win scenario. Money has to come from somewhere, so if the lender is making money, and you are making money, then where is that money coming from? The next buyer (the future). The lender is making money on you, and you're making money on the next buyer (unless you buy a house that isn't worth as much as you paid for it or it depreciates, or a slew of other things happen).

This was a large one to tackle. Please comment and ask questions. Other people reading this will probably have the same questions, so you'll be helping them out too!

Sunday, November 6, 2011

Savings Account

All savings accounts offer some small rate of return, usually between .25% and 1.5%. Is this rate insignificant, or is it worth caring about? The answer: probably insignificant.

First some definitions:

  • Monthly compounding interest: This is usually stated as 1.5% per year compounding monthly. What this really means is each month, the average daily amount in your account times one twelfth (because there are twelve months per year) of 1.5% is added in as your interest for that month. Obviously by adding in that amount each month, the second month contains a little interest on the first month's interest, and in the third month, the interest that was accrued in months one and two are both included in the amount for which the interest is calculated.

Math Time
Let's start by defining some variables:
  • S = Starting amount
  • F = Final amount
  • p = number of periods in a year (p = 12 if we're dealing with monthly compounding)
  • r = annual interest rate (.0025 <= r <= .015, or r is between .25% and 1.5%)
  • y = the number of years we let it continue to get interest (note: we can use whole years, or we can use parts of year, but only in denominations of p. In other words we can have 1/12, 2/12, 3/12, and so on as values for y if we're dealing with months, i.e. p = 12.)

  1. From Interest Math, we know that when p = 1, meaning we are dealing with annually compounding interest, that we get S(1+r)^y = F. Let's follow the same logic to get our periodically compounding interest.
  2. What happens after the first period (after the first month if p = 12)? S + S*(r/p) = F. Here we are adding the fractional interest accrued over the first period. Factoring out the S gives us S(1+r/p) = F
  3. For the second month, S + S*(r/p) + (S + S*r/p) * r/p = F. Let's distribute the r/p: S + S*r/p + S*r/p +S*(r/p)^2 = F. Let's combine terms and factor out an S: S(1 + 2(r/p) + (r/p)^2). This looks just like the annually compounding interest! Clever mathematicians will realize that 1 + 2(r/p) + (r/p)^2 = (1 + r/p)^2
  4. This same idea holds going forward, so we get S(1+r/p)^(p*y) = F. Again, this can be proven rigorously using Mathematical Induction.

We know F in terms of S, r, p, and y. What about the other forms?

Final Answers
Using basic algebra (a little more for logs) we get:
  • F = S(1+r/p)^(p*y)
  • S = F/(1+r/p)^(p*y)
  • r = ((F/S)^(1/(p*y)) - 1) * p
  • p is not nice .. leave a comment if you can figure this one out
  • y = log(F/S) / (p*log(1+r/p))
Lets make a table showing for $1,000, $5,000, and $20,000, how much you would make the first year with .25% and 1.5% interest:
  • For $1,000:
    • At .25%, 1000(1 + .0025/12)^12 = $1,002.50 or $2.50 in interest
    • At 1.5%, 1000(1 + .015/12)^12 = $1015.10 or $15.10 in interest
  • For $5,000:
    • At .25%, $5,012.51, or $12.51 in interest
    • At 1.5%, $5075.52, or $75.52 in interest
  • For $20,000:
    • At .25%, $20,050.06 or $50.06 in interest
    • At 1.5%, $20,302.07 or 302.07 in interest
If you don't have much money, then you should be looking at this and thinking "15 bucks a year ... for saving $1000 ... that's pretty skimpy". If you have $20,000 saved up, then you probably won't notice 50 to 300 bucks a year, or between $4 and $25 a month.

At the best rate banks will offer for savings, you might be getting more squat but it still amounts to diddly. 

Thursday, November 3, 2011

Investment Math

Recently, a mathematical question popped into my head: "What annually compounding interest rate is required to double your money every five years?" The answer is just under 14.87%. Good luck with that!

First some definitions:

  • Annually Compounding Interest: Suppose you have $10 invested in something that returns 10% per year. After one year, you have $11 = $10 + $10 * 10%. After two years you have $12.10 = $11 + $11 * 10%. Each year, your current amount (not your starting amount) grows by 10%.
  • Annually means yearly.
  • Non-compounding interest: Taking the same example as above, First you have $10, then you have $11, then you have $12. Each year, you get 10% of your starting amount.

Math Time
Let's start by defining some variables:
  • S = starting amount
  • F = final amount
  • y = number of years to go from starting amount to final amount
  • r = annually compounding interest rate

  1. What is the relationship between these numbers? We know that when y = 0, S = F regardless of what r is.
  2. When y = 1, S + S*r = F, or by factoring out an S, S(1+r) = F.
  3. For y = 2, S + S*r + (S + S*r) * r = F. The original amount S, plus the first year's interest S*r, plus the second year's interest which is the interest rate times the amount after the first year's interest is added, or (S + S*r) * r. After distributing the r we get S + S*r + S*r + S*r*r which after factoring out the S becomes S(1 + 2r + r^2). And of course 1 + 2r + r^2 = (1 + r)^2. So to reiterate, S(1+r)^2 = F.
  4. Following this trend it becomes obvious that for number of years y, S(1+r)^y = F (which can be proven formally using mathematical induction).

So now we know how to find F given S, r, and y. What about each given the others?

Final Answers
Using mostly basic algebra we get:
  • F = S(1+r)^y
  • S = F/(1+r)^y
  • r = (F/S)^1/y - 1
  • y = log(F/S) / log(1+r)
If you're a calculus nerd, and you only know two of the four variables, then you can set the first derivative equal to zero to find local maxima or minima ... nerd.

So what annually compounding interest rate is required to double your money every five years?
r = (2S/S)^1/5 - 1 = 2^1/5 - 1. The fifth root of 2 is roughly 1.1487, so r = .1487 or 14.87%.