One can imagine two simplifying cases for how a non-uniform grade may be approached. One is to ride it at constant speed. In this case, estimating the effect of wind resistance on power is simple: in still air (or a constant relative wind) and with a fixed riding position ride wind resistance is constant. Obviously power fluctuates, perhaps wildly as the grade changes. Interestingly, from a pure physics standpoint this is the most efficient way to climb the hill. For a given speed, it minimizes energy used.
However, physiologically it may not be efficient. There is an increasing marginal cost associated with producing higher powers than lower powers. As a fraction of your functional threshold, it's likely more difficult to alternate 1-minute intervals between 150% and 30% than it is to stay at a steady 90%, even though the average power is the same. It is for this reason the "normalized power" concept (a weighted average power) was invented. But that's off-topic.
An alternate approximation is that power is held constant. This may be considered a physiologically efficient approach in the limit of an infinite normalized power coefficient. With this approach, to stay at a near-optimal cadence, a lot of shifting may be involved, which may provide its own inefficiencies. But this analysis ignores shifting issues, of course.
A realistically optimized power schedule is neither constant speed nor constant power. But discussing that is way beyond the scope of this analysis. We'll assume constant power is the better choice of the two.
Furthermore, the analysis will again use the "quasi-static" approximation of ignoring acceleration power. Everyone knows if you go down one side of a dip you can coast part way up the other side. This analysis assumes you instantly hit terminal velocity going down, then need to start pedaling immediately when you hit the opposite side. This coasting effect, due to inertia, tends to smooth out the effective grade somewhat. So the grade variations discussed here are those which can't be smoothed over with coasting. For example, every small bump in the pavement isn't counted.
Okay, enough discussion. We assume constant power and neglect inertia.
The usual model: we have a wind resistance component of power
pw = fw (s ‒ sw)² s,
where s is bike speed and fw is a coefficient. We also have a mass-proportional component of power
pm = fm m s,
where m is total mass and the coefficient fm is modeled as:
fm = g ( cRR + grade ),
where g is the acceleration of gravity, cRR is the coefficient of rolling resistance and grade is the road grade (linear approximation).
These power components can be combined to get total power (neglecting drivetrain losses, which as usual we assume are proportional to total power, and end up not affecting the final result):
p = pw + pm.
I'll hit the calculus next post.