This was inspired by a blog entry I made about home buying. My original goal was to work through a set of calculations about the merits of renting vs buying. After several discussions with various people about the topic, I decided I should automate the calculations.
As far as I know, all of the calculations here are correct, but I can't guarantee anything. Get some proper advice from a financial planner (while keeping in mind any economic factors that might influence their advice).
One thing that is clear: I haven't done inflation right. I was trying to keep everything in current-dollars (i.e. ignore inflation). But, the mortgage payment (at least) is inherently affected by inflation (it decreases in inflation-adjusted value since the dollar amount stays the same).
Summary
Buying
Buy a house worth $500000 with a total monthly payment of $3733.79. You expect it to be worth $824017.6 after 25 years.
Renting
Rent a place for $1700 and invest $2033.79 per month. You expect this to be worth $1639699.83 after 25 years.