I think my formula is just plain wrong.
Suppose I have a completely level ride. If the atmospheric pressure changes so my altimeter reading decreases, I will show no accumulated climbing at all. So I shouldn't correct the reading at all. If the altimeter reading steadily increases, then the device will show that I have accumulated some climbing, and indeed I should subtract off the gain to get the correct figure.
Suppose my ride is a long gradual decline, and then a short steep climb back to my starting point. Suppose the pressure is changing steadily, so a fixed altimeter would show an increasing elevation. My short steep climb is quick enough that the pressure doesn't change much, so the accumulated climb measured for that part of my ride would be accurate. But look at the measurement for my long slow decline. If the pressure is changing fast enough, that will actually look to the device like a climb, and a correction should be applied. If, on the other hand, the pressure change is slower, then it will look to the device like downhill movement and no climbing will be accumulated - thus, no correction should be applied.
Math is cruel!