When are solar panels worth the investment in your home?

When are solar panels worth the investment in your home?
It's worth doing the math before making the switch to solar.