Assume g is monotonic, i.e. one to one, and differentiable on the interval [a,b]. Let f be differentiable on the interval [g(a),g(b)]. We can integrate f′ over this interval, giving f(g(b))-f(g(a)). At the same time, we can integrate f′(g)×g′ on [a,b], and since the integrand is the derivative of f(g), the resulting formula is once again f(g(b))-f(g(a)). We can integrate f′ on its domain, or f′(g)×g′ on its domain; the result is the same.
If g is constant on [a,b], the integral of f′ from g(a) to g(b) is 0, since g(a) = g(b). Also, the integral of f′(g)×g′ is 0, since g′ is 0. Again, the two answers are the same.
If g is a finite union of monotonic and constant sections, add integrals together to show the integral of f′ from g(a) to g(b) is still the integral of f′(g)×g′ from a to b. Finally, g may have infinitely many increasing and decreasing sections as we approach an end point. All the integrals that don't quite reach the endpoint are equal, since g has a finite number of increasing and decreasing sections. The subintegrals are equal, and the indefinite integrals are equal. Remember, indefinite integrals and definite integrals coincide on closed intervals, so integration by substitution works for almost any g you can imagine.
We haven't really talked about trig functions yet; they're coming up in a few short sections. Let's say you know that the derivative of sin(x) is cos(x), so we can do these examples.
Assume you want to integrate cos(x3)×3x2 from 0 to 2. Let g = x3, hence we are integrating cos(g)×g′. Integrate with respect to g, as g runs from 0 to 8, the analogous interval for x = 0 to 2. The integral is sin(g), and the area under the curve is sin(8)-sin(0) = sin(8). If we want a general formula for the area, in terms of x, substitute g = x3 to get sin(x3).
Substitution can be used in reverse. Assume f is the integral of 1 over the square root of 1-x2, from 0 to 1. The integrand is a function that starts at 1 (above the origin) and swoops up to infinity as x approaches 1. Thus we are trying to compute an indefinite integral, namely the integral of f′ on [0,1), but we don't really know how to integrate f′. Fortunately substitution works for indefinit integrals. Think of x as a function, sin(θ). Thus the integrand becomes f′(sin(θ) times the derivative of sin(θ), as θ runs from 0 to π/2. Remember that 1 - sin2 is cos2, thus the transformed integrand becomes cos(θ)/cos(θ), or 1. Integrate to obtain θ, evaluate at the end points, and obtain the area π/2. An unbounded curve can indeed wall off a finite area beneath.