Let's explain these parameters better. My understanding is that this function computes $\frac{d}{dx} (t_r - y_{ui})$, and that `r` specifies what t_r is used, and `k` speficies `x` (with `k=0`, $x = t_1$`; for `k > 0`, it is $x = β_k$).