Compared to the other answers, I feel like I'm taking crazy pills, because:
Is my following calculation correct?
Sorry to be the bearer of bad news, but no, this is not correct.
In 3 years, if the market gets soft, and I have to sell the house for $200,000. Am I still better off than renting, because, $180,000 (taking off 20k for the realtors and closing costs), less $220,000 ($40,000) is still smaller than 54k?
The math here is backwards. You have to add those two numbers together, not subtract! In the situation you described, after 3 years, you are out 54K+40K = $94K if you buy, vs $54K if you rent. (Because you pay the same $54K for the mortgage, and then you lose another $40K when you sell.) Then you get to subtract out whatever equity you've earned on the mortgage, which after 3 years will be somewhere in the $12K-37K range depending on what your rate and term are. Even in the best case scenario ($37K) you are still out 94-37 = $57K if you buy. You also said the $1500 was for your mortgage, but didn't mention taxes, insurances, and other fees. If those are not included in your mortgage payment then your starting number is going to be much higher than $1500/month. If they are included, then the amount of equity you are going to get is going to be much less than $37K. Note: you'll be able to deduct some of the interest and tax payments too, which will help lower the overall cost too.
If you are pretty sure you are going to be selling your home in as soon as 3 years, it's probably not going to make financial sense.
As a side note, a friend of mine recently sold his home that he owned for 12 years. He sold it for $50K less than he paid, but had gained enough equity that after adding up all his costs for 12 years he estimated he came out ahead approximately $100/month by owning vs renting an equivalent home. Note this also factored in the tax deduction advantage of owning a home. They key difference here is that he had 12 years to earn equity vs your scenario which is only 3 years.