The problem with this math is that panels won't last 20-25 years without maintenance, and what energy cost does that maintenance account for. With warranty periods maxing out at 10 years, I'm skeptical that they would last 20-25 years without intervention.
Back when I read magazines like Home Power, people were saying their panels tended to last up to 30+ years with minimal maintenance, and still produce most of their power[1]. The batteries, OTOH, won't last nearly that long.
[1] I'm sure a lot of that's anecdotal, but I have never seen actual studies done. Plus, I think "maintenance"--at least as far as the panels are concerned--mainly consists of "keep them clean".