The other day I was wondering about gym decay rate, and was surprised to find that no one had figured out the exact formula yet. Granted, gym decay is somewhat unimportant in the current metagame, as expending any mental effort on defending is a waste of time. But despite numerous posts like these, there still wasn't a finite Gym decay rate algorithm out there.
Since I was last writing, the game has changed significantly, and so have I. For one thing, I live on the other side of the world, and with the change to gym mechanics, my gym motivation decayed significantly as well. But my current location gives me a great group of local gyms that are either high-turnover or hold for up to 4 days undisturbed. So I decided I would test Pokemon over a wide range of CP to determine exactly how gym decay changes with CP.
You can find this calculator, my 250-1299 calculator, and my 2321+ calculator on the Let's GO Decay Rate Calculator page, but I've pasted in the 1300-2321CP calculator here for folks to see.
Let's be honest, this is like... the only thing you care about in this article. Find the 2322+ calculator on the Let's GO Decay Rate calculator page here! I'll be updating the calculator page with calculators for below 1300 CP as well when more data becomes available. Unfortunately I suck at code and so I haven't yet figured out how to merge all three calculators into one.
Disclaimer: In testing this calculator against my recorded data, there was no difference in predicted CP/h greater than 0.30, and no difference in predicted %CP/h greater than 0.01% within the bounds of 1300-2321 CP.
But to see how I've come up with this calculator, read on! Note that the calculator only applies between 1300 and 2321 at the moment. Above ~2321, decay rate is 10% of the Initial CP, and so you can just use the formula (Initial CP)*(0.1) to find your CP/h decay rate, and any %CP/h or "Time until" numbers are the same as CP = 2321.