I have found these sentences in my book:
Two additional formulas are used in the computation of the expected value of a function of X when X ≥ 0. Let X have pmf or pdf f(x) with support S and cdf F(x), and let G(x) be monotone where G(x) ≥ 0. If X is continuous we assume G(x) is differentiable with $\frac{d}{dx}G(x)=g(x)$ and that E{G(X)} exists; then using integration by parts, the expectation takes the form $$E[G(x)]=G(0)+ \int_{S}^{}g(x)[1-F(x)]dx$$
I tried to use integration by parts to derive the formula but fail. Could someone explain how to get the formula from $E[G(x)]=\int_{S}^{}G(x)f(x)dx$?