Coal-fired power is on pace to collapse in the United States and Europe over the next two decades, and will peak worldwide in nine years, according to a long-term forecast released on Thursday.

Solar and wind energy, meanwhile, will dominate over the next 23 years, comprising nearly three-quarters of the expected $10.2 trillion in new electricity investments.

“This year’s report suggests that the greening of the world’s electricity system is unstoppable, thanks to rapidly falling costs for solar and wind power, and a growing role for batteries, including those in electric vehicles, in balancing supply and demand,” Seb Henbest, lead author of Bloomberg New Energy Finance’s 2017 New Energy Outlook report, said in a statement.

As a result, carbon pollution from the power sector will reach its apex in 2026. By 2040, emissions are forecast to be 4 percent below 2016 levels.

That prediction depends on a few things:

The cost of installing wind turbines needs to fall. That seems likely. With offshore wind, which is booming in Europe, but only just starting in the Northeastern U.S., the analysis predicts prices will plummet 71 percent by 2040. Onshore wind costs, which have already dropped 30 percent over the past eight years, are expected to decline by an additional 47 percent on the same timeline as its seaborne sister sector.

Batteries need to improve and become widespread. The market for lithium-ion batteries, like the ones that power Tesla’s electric vehicles, could be worth at least $239 billion by 2040, which would allow utility-scale renewable projects to compete with natural gas made cheap by the drilling process known as fracking. But utilities are just one part…