Compute the Riemann-Stieltjes integral $$\int_{-1}^{1}\cos x \ \mathsf dg(x),$$ where $g(x) = -\mathsf 1_{[-1,0]}(x)+3\cdot \mathsf 1_{(0,1]}(x)$.
Solution: $$\int_{-1}^{1}\cos x\ \mathsf dg(x) = f(c)(g(c^{+})-g(c^{-})=\cos(0)(g(0^{+})-g(0^{-}))=1*(3-(-1))=4$$
Could someone tell me if I have solved this correctly?
Your answer is correct. Rigorously, if we take any partition $-1=x_0<x_1<...<x_n = 1$, then the nature of $g$ dictates that in the expression for the upper or lower Riemann-Stieltjes sum , only that interval contributes which contains $0$ ; that term will look like $\inf_{[x_j,x_{j+1}]}[\cos(x)][3-(-1)] = 4(\inf_{[x_j,x_{j+1}]}\cos(x))$ (or $\sup$ for the upper RS sum). As $\cos$ is continuous, this term converges to $4 \times \cos 0 = 4$ for the upper and lower case.
In this case $g$ is differentiable except at one point where it has a jump discontinuity : for these kind of functions it is possible to create a general formula for the RS integral in terms of the derivative, and the amount of jump at the point. One can express the jump unrigorously as a "delta function" contribution in the derivative, and proceed to evaluate as if $dg(x) = g'(x)dx + \delta$ term. In this case, $g' \equiv 0$ when defined and the value of the jump is $4$ at the point $0$, so we get $dg(x) = 0dx + 4\delta_0$, and upon integration, only the delta remains : $4\delta_0(\cos(x)) = 4 \cos 0 = 4$.