Let $$f(x)=\begin{cases} 0, & x=-1 \\ 1, & x \in (-1,2) \\ -1, & x \in [2,3] \end{cases}$$ then the question is to find out the value of $$\int_{-1}^{3} x\;d(f(x))$$
Here is what I tried $$\begin{aligned} \int_{-1}^3 x\;d(f(x)) &= \int_{-1}^3 xf'(x)\;dx \\ &= xf(x)\Bigr|_{-1}^3 - \int_{-1}^3 f(x)\;dx \\ &= 3 - 1 - \int_{-1}^2 dx + \int_2^3 dx \\ &= 2 - 3 + 1 = 0 \end{aligned}$$
However I am not getting the correct answer. Please help me in this regard. Thanks.