# Mean Square Error

I am ready the 101 page of the book [1], and I have a doubt. How I will be able to say: If $\sigma=\sum_{i=1}^{L}\int_{t_i}^{t_{i+1}}(u-r_i)^2p(u)du=0$; where $u$ is a scalar random variable with continuos density function $p(u)$. Then

$$\dfrac{\partial \sigma}{\partial t_k}=(t_k-r_{k-1})^2p(t_k)-(t_k-r_k)^2p(t_k)=0?$$

I begin first each each summand equal to zero, then a one summand of $\sigma$ is $$\sigma_i=\int_{t_i}^{t_{i+1}}u^2p(u)du-2r_i\int_{t_i}^{t_{i+1}}up(u)+r_i^2\int_{t_i}^{t_{i+1}}p(u)du$$

[1] Anil Jain, Fundamentals of Digital Image Processing.

-

The derivative is zero because $\sigma$ is identically zero. As far as your question concerns how to obtain that expression for the derivative, note that differentiating an integral with respect to one of its limits yields the integrand evaluated at the limit, with positive sign in case of the upper limit and with negative sign in case of the lower limit. For $1\lt k\le L$ the variable $t_k$ occurs in two contributions to the sum, namely for $i=k$ and for $i=k-1$. Thus we have

\begin{align} \frac{\partial\sigma}{\partial t_k} &=\frac\partial{\partial t_k}\sum_{i=k-1}^k\int_{t_i}^{t_{i+1}}(u-r_i)^2p(u)\,\mathrm du \\ &= \frac\partial{\partial t_k}\left(\int_{t_{k-1}}^{t_k}(u-r_{k-1})^2p(u)\,\mathrm du+\int_{t_k}^{t_{k+1}}(u-r_k)^2p(u)\,\mathrm du\right) \\ &= (t_k-r_{k-1})^2p(t_k)-(t_k-r_k)^2p(t_k)\;. \end{align}

Note that this expression isn't valid for $k=1$ and $k=L+1$; in those cases there's only one contribution each, and we have

$$\frac{\partial\sigma}{\partial t_1}=-(t_1-r_1)^2p(t_1)$$

and

$$\frac{\partial\sigma}{\partial t_{L+1}}=(t_{L+1}-r_L)^2p(t_{L+1})\;.$$

-