Now suppose that I get one new data point, yk+1. The new value of u1 is:
(28)
Here I'm using the '+' superscript to indicate the updated version of u1. Looking at the two values, it's clear that:
(29)
You can implement this algorithm very efficiently by keeping the y's in a circular buffer. Subtract the oldest value, replace it with the newest one, and add that one to the sum.
Computing u2, the second term in U, is trickier because of our need to deal with the new offset in the x-values. Before the update, u2 will be:
(30)
After processing the new data point, it's going to be:
(31)
Subtracting the "before" and "after" forms tells us what we must do to update the summation. We get:
(32)
Now look at the sum inside the parentheses in Equation 32. It looks suspiciously like the sum in u1+. In fact, we can write:
(33)
Therefore, I can write:
(34)