Riemann-Stieltjes integral with respect to a discontinuous function I have to find if the function $f(x)=x^2$ is Rieman-Stieltjes integrable respect to the function $g(x)=3x$ if $x\in[0,1)$ and $g(1)=4$. Now, because $f$ is continuous and $g$ is of bounded variation, the integral indeed exists. To find the value of the integral, I chose to find the integral:
$$\int_0^1f(x)d(g(x))-\int_0^1f(x)d(3x)$$
By definition of $g$, this is:
$$\int_0^1f(x)d(h(x))$$
Where $h(x)=g(x)-3x$, so $h(x)=0$ for $x\in[0,1)$ and $h(1)=1$
Finding it by definition, if $\epsilon>0$, and I chose the partition $P=\{0,1-\epsilon,1\}$, then:
$S(P,f,h)=f(0)(h(1-\epsilon)-h(0))+f(1-\epsilon)(h(1)-h(1-\epsilon))=f(1-\epsilon)=(1-\epsilon)^2$
From here, I could conclude that:
$$\int_0^1f(x)d(h(x))=1$$
Is this correct? Because intuitively I thought it was going to be $0$, or did I do something wrong?.
 A: Since $f$ is increasing, the lower and upper sums for the partition $\{0,(1- \epsilon),1\}$ are
$$L(P,f,h) = f(0)(h(1-\epsilon) - h(0)) + f(1-\epsilon)(h(1) - h(1-\epsilon))\\=0 \cdot (0 - 0) + (1-\epsilon)^2(1 - 0)= (1-\epsilon)^2, $$
and
$$\\U(P,f,h)=  f(1-\epsilon)(h(1-\epsilon) - h(0)) + f(1)(h(1) - h(1-\epsilon)) \\ (1-\epsilon)^2 (0 - 0) + (1)^2(1 - 0)= 1,$$
The integral must fall in between the lower and upper sums,
$$(1-\epsilon)^2 \leqslant \int_0^1 f \, dh \leqslant 1$$
Since the limits as $\epsilon \to 0$ of the LHS and RHS are both $1$, it follows that the integral has a value of $1$.
Thus,
$$\int_0^1f \, dg = \int_0^1 x^2\, d(3x) + \int_0^1 f \, dh  = 3 \int_0^1 x^2 \, dx + 1 = 2$$

In general, to compute the value of the integral with Riemann-Stieltjes sums, you should take the limit of a sequence of sums corresponding to partitions $P_n$ with $\|P_n\| \to 0 $ as $n \to \infty$.
Taking $P_n = \{0,\frac{1}{n},\frac{2}{n}, \ldots, \frac{n-1}{n},1\}$, we have
$$S(P_n,f,g)= \sum_{k=1}^{n-1} \left(\frac{k}{n} \right)^2\left(3\frac{k}{n} - 3\frac{k-1}{n} \right)+ (1)^2 \left(4 - 3\frac{n-1}{n} \right) \\ = \frac{3}{n^3}\sum_{k=1}^{n-1}k^2+ 1  + \frac{3}{n} ,$$
and we have
$$\int_0^1 f \, dg = \lim_{n \to \infty}\left(\frac{3}{n^3}\sum_{k=1}^{n-1}k^2+ 1  + \frac{3}{n}\right) = 3\cdot \frac{1}{3} + 1 = 2$$
