Home prices in the U.S. are up by more than 33% over the past six years, and mortgage rates have started to rise from their historical lows. Additionally, low inventory levels have created one of the biggest seller's markets in recent history. As a result, in many locations where it had been significantly cheaper to buy a home than rent, this is no longer the case.

US House Price Index Chart

U.S. House Price Index data by YCharts.

However, the logic behind comparing the monthly costs of homeownership and renting is flawed. Here's a closer look at the financial mathematics of buying a home and why, from a financial standpoint, it's typically far better to own your home.

The easy comparison might favor renting

For several years after the housing bubble burst, it was much easier to make a strong mathematical case for buying a house in most parts of the United States. Depressed housing prices combined with record-low interest rates meant that it was often cheaper on a monthly payment basis to buy, even when factoring in property taxes and insurance costs.

Today, this isn't the case in many major markets. When you simply look at the cost per month, it's often cheaper to rent. When you consider the uncertainty of maintenance costs that come with homeownership, it might seem like a no-brainer to continue renting.

Don't forget about equity

No mathematical comparison between buying and renting would be complete without taking into account the fact that homeowners build equity while renters do not.

Couple and child standing in front of new home with keys in hand.

Image source: Getty Images.

Let's say for example that you buy a home for $200,000 and put 20% down, which would translate to a $764 monthly mortgage payment at the current 30-year mortgage interest rate of about 4%. At first, only about 31% of your mortgage payment will be used to reduce the principal, with the rest going toward interest. After the first year, you'll have paid down approximately $2,800 of the loan's balance.

Keep in mind, however, that this is $2,800 of equity a renter would not have built. And, as your loan progresses, an increasing percentage of each monthly payment will go toward the principal.

The real comparison tells a different story

As a simplified example, let's say that you can rent a three-bedroom apartment for $1,000 per month, or you can buy a three-bedroom home and pay $1,000 per month on your mortgage, including taxes and insurance. So, on the surface, your monthly housing payments are identical.

However, like I said earlier, about 31% of your $1,000 mortgage payment, or $310 per month, will go toward building equity, which can eventually be recouped (theoretically) when you sell the home. If you just wanted to stick $310 per month in a savings account instead, you'd need to find an apartment to rent for just $690 per month to make the situation financially equivalent.

And this is just the effect in year one. By the tenth year of your mortgage, 45% of your payment, or $450 per month, will be applied to the principal. So, now you'd need to find a rental for just $550 per month to make up for the difference. As you can see, the financial situation between owners and renters gets more and more uneven as time goes on.

In addition, keep in mind that while the monthly principal and interest payment on a 30-year mortgage will remain the same for three decades, that's not likely to be the case with your rent. Over time, the average cost of rental housing has increased at about 3% per year.

This means that in year 30, you can expect your rent to be 2.4 times what you're paying now. On our $1,000 original monthly rental budget, that means you can expect to pay about $2,400 per month for rent in 30 years. In all, you will have paid $612,000 for rent over 30 years, assuming 3% annualized rent increases, and you'll have nothing to show for your money. Or, you could pay a total of $360,000 on a mortgage, and own your home free and clear, which will likely be worth significantly more than its original purchase price by that time.

Homeownership isn't for everybody, but it usually makes good financial sense

To be fair, not everyone should own a home. This is especially true for people who don't know if they'll own the home for at least five years or so. If you don't think you'll keep the house that long, or simply want the freedom to relocate at any time, renting is probably the way to go.

The same can be said for people who live with roommates, because in this case, renting is generally the cheaper way to go, even if you factor in the equity you're building. As I mentioned before, only about 30% of your mortgage payment goes toward equity each year at first, and by living with one roommate, your cost of renting a particular home drops by 50%. Of course, this is a simplified example, but if you're willing to give up some of your privacy and live with other people, it can be cheaper to rent.