Q: If you have a fixed-rate mortgage, why would you want to refinance if you plan to stay in the home for the duration of the mortgage?

?

A: There are many reasons to refinance your 30-year or 15-year fixed-rate mortgage. The first and best reason: to save money.

When Sam bought his first home, back in 1987, he took out a 30-year fixed-rate mortgage with an interest rate of 12.75 percent. Any meaningful drop in interest rates after he took out that loan meant he could refinance and save a bundle of money over the remaining years on his loan.

Over the past 10 years or so, interest rates have remained extraordinarily low. The 30-year fixed rate has fluctuated between about 5.6 percent in June 2009 and a low of about 3.3 percent in December 2012, according to the Federal Reserve Bank of St. Louis website. Today the 30-year fixed rate stands around 4.5 percent.

If you locked in a loan at 4 percent and interest rates never fell below that level again, you might not be able to save money by refinancing. If interest rates fall below that point, it might be a smart move to refinance and obtain a lower interest rate.

But not all refinancing is worth it. If the interest rate is marginally lower and the costs to refinance are high, you could be worse off with a new loan.

We’ll try to describe it simply. If you take out a $200,000 loan today for 30 years at 4.5 percent, you’ll have a monthly payment of about $1,013. (This does not include real estate tax or insurance payments.)

If interest rates drop to 4 percent a year later and you refinance, your new 30-year mortgage payment would drop to about $954 but — and this is important — you’d have added a year of payments to the loan. Your old loan would have been paid in full in 2049 and the new loan would be paid off in 2050.

To compare these loans, you’d want to figure out what your payment would be if you paid off the new loan in 2049 so that it would terminate at the same time as the old loan.

Using simple online amortization calculators, you can compute what you’d need to pay on your new loan to get it paid off in 29 years: about $972 per month. So the actual difference in the monthly payment on the old loan at $1,013 and the new one at $972 is a savings of about $41 per month.

Here’s the key: You need to know what it will cost to refinance. Remember to exclude tax and insurance escrows or other payments that you’d make no matter what. When the lender tells you that you’ll have to pay title company or settlement company fees of $2,000, along with recording or other government fees of $500, you’ll know that your closing costs will be about $2,500. Because you save $41 per month on the new loan, it will take a bit more than five years to break even on the refinance.

Spending $2,500 today and saving only $41 per month may not be worth it. Having said that, if you actually refinance and keep that loan until 2049, you’ll save over $20,000 over the life of the loan.

We’ve made many assumptions, of course, and the reality is that most Americans don’t stay in their home for 30 years. You’d want to balance the odds that you’ll stay in a home for a given length of time with the savings you’ll get from refinancing. The lower interest rates go and the lower the costs to refinance, the better you do in the short term and over the length of the loan.

Ilyce Glink is the CEO of Best Money Moves and Samuel J. Tamkin is a real estate attorney. Contact them through the website ThinkGlink.com.