My question is related to the posts here and here, but my setup is slightly different.
For a real-valued random variable $X$, and a function $\varphi: \mathbb{R} \to \mathbb{R}$ that has support in some interval $[c,d] \subseteq \mathbb{R>0}$ (i.e. outside this interval we have $\varphi(x) = 0$), such that $\varphi|_{[c,d]}$ is continuous with continuous derivative. I want to show that
$$\mathbb{E}[\varphi(X)] = \varphi(c)\mathbb{P}(X\geq c) + \int_{c}^{\infty}\varphi^{\prime}(u)\mathbb{P}(X\geq u)du.$$
My attempts so far are not succesful, because I am not sure how to handle the possible discontinuities at $c$ and $d$, because the derivative may not exist here. I have tried to follow the same steps as in the other discussions, since I do have that $\varphi(0) = 0$, so therefore by the fundamental theorem of calculus we have for $x \geq c$ that$$\int_{0}^{x}\varphi^{\prime}(u)du = \varphi(x),$$and therefore$$\begin{align} \int_{-\infty}^{\infty}\varphi(x)d\mathbb{P}(x) &= \int_{-\infty}^{\infty}\int_{0}^{x}\varphi^\prime(u)du d\mathbb{P}(x),\\\\&= \int_{-\infty}^{\infty}\int_{0}^{\infty}1_{\{x >u\}}\varphi^\prime(u)du d\mathbb{P}(x)\\\\&= \int_{-\infty}^{\infty}\int_{0}^{\infty}1_{\{x >u\}}\varphi^\prime(u)du d\mathbb{P}(x)\\\\&= \int_{0}^{\infty}\varphi^{\prime}(u)\int_{-\infty}^{\infty}1_{\{x >u\}} d\mathbb{P}(x)du\\\\&= \int_{0}^{\infty}\varphi^{\prime}(u)\mathbb{P}(X\geq u)du\end{align}$$Here the 1 denotes the indicator function for $x < u$, and $\varphi^{\prime}$ the continuous derivative of $\varphi$ restricted to $[c,d]$. I used Fubini in line 4 to change the order of integration. I feel something is wrong, and I should use probably use some kind of generalised derivative of the form$$x \mapsto \varphi(c)\delta_{c}(x) + \varphi_{c}^{\prime}(x)\delta_{(c,d)}(x) + \varphi(d)\delta_{d}(x)$$where the $\delta$ are indicator functions, and $\varphi_{c}$ is the continuous derivative of the restriction of $\varphi$ on $[c,d]$. But then I am not sure if the fundamental theorem of calculus (or some variant of it) can be applied. Suppose this were possible, then it would be tempting to continue from what I had and write$$\int_{0}^{\infty}\varphi^{\prime}(u)\mathbb{P}(X\geq u)du = \varphi(c)\mathbb{P}(X\geq c)+\int_{c}^{\infty}\varphi^{\prime}_{c}(u)\mathbb{P}(X\geq u)du$$since the derivative is 0 for all $u < c$. Any help is appreciated!