# Derivative of expectation where the variable appears in the integration limit and in the integrand?

I want to calculate the derivative of

$$\varphi(\mu) = \int_{-\infty}^{\mu} r(x-\mu) f(x)dx,$$ wrt to $$\mu$$, where $$r$$ is a function and $$f$$ is a density function. How can I account for the presence of $$\mu$$ in the integration limit and in the function inside the expectation?

Consider any differentiable function $$f:\mathbb{R}^2\to \mathbb{R}.$$ It is a theorem that the derivative of $$f$$, written $$Df,$$ is given by its partial derivatives,

$$Df(x,y) = \left(\frac{\partial f}{\partial x}(x,y), \frac{\partial f}{\partial y}(x,y)\right).$$

Let $$\iota:\mathbb{R}\to\mathbb{R}^2$$ be given by

$$\iota(x)=(x,x)$$

and note that this is differentiable with

$$D\iota(x) = (1,1).$$

To differentiate the expression $$f(x,x),$$ compose $$f$$ with $$\iota$$ and apply the Chain Rule thus:

$$Df(x,x) = D(f\circ \iota)(x) = Df(\iota(x))\circ D\iota(x) = \frac{\partial f}{\partial x}(x,x) + \frac{\partial f}{\partial y}(x,x).$$

To obtain the answer, apply this result to the function

$$\varphi(\mu,\nu) = \int_{-\infty}^{\mu} r(x-\nu) f(x)dx.$$

The derivative with respect to $$\mu$$ is (of course) obtained with the Fundamental Theorem of Calculus. The derivative with respect to $$\nu$$ can be computed by differentiating under the integral sign provided $$r$$ is continuously differentiable.