A single exponential moving average has a structural flaw: on a series with a steady trend it always lags behind. By the time it catches up to where the series was, the series has moved on.
Holt's method (double exponential smoothing) fixes it by tracking two things instead of one — the current level and the current trend — and updating both at every step.
Read the first line as the EMA recursion with one change: instead of mixing toward the old level, it mixes toward the old level plus the trend — the level's own forecast of where it was heading. The second line is the same recursion applied to the trend, which is estimated by how much the level just moved.
Task: write holt(series, alpha, beta) returning the level at every time step, each rounded to 4 decimal places.
Initialisation: level = series[0] and trend = series[1] - series[0].
series[0] itself.The pay-off is visible on a straight line: feed in 10, 20, 30, 40 and Holt reproduces it exactly, because it has learned the trend of +10 and keeps applying it. A single EMA on the same input trails behind at every step.