# u-substitution shows 0=1

This question/observation is inspired by the integral:

$$\int_0^{\sqrt{\pi}}x\sin(x^2)\cos(x^2)dx$$

The $$u$$-substitution $$u=\sin(x^2)$$ yields $$du=2x\cos(x^2)dx$$ and

$$\int_0^{\sqrt{\pi}}x\sin(x^2)\cos(x^2)dx=\frac{1}{2}\int_0^0 u du=0,$$

right? Wolframalpha certainly agrees.

Great, now consider the much harder integral $$\int_0^1 dx.$$

After banging our heads against the wall for hours we take $$u=x^2-x$$ so $$du=(2x-1)dx=\pm\sqrt{1+4u}*dx$$ by the quadratic formula, so

$$\int_0^1 dx=\int_0^0\frac{du}{\pm\sqrt{1+4u}}=0$$

The problem is wolframalpha says this integral should be $$1$$. Well, I guess it is a unit square.

Since $$0\neq 1$$ there is something fishy going on - I'm just trying to fully nail down the issue here. I think it boils down to hidden division by $$0$$ like most false proofs. In particular we can't solve the equation $$du=(2x-1)dx$$ for $$dx$$ if $$x=\frac{1}{2}$$, which happens inside the domain of integration. This isn't a problem for the original integral because even though there is a place where $$\frac{du}{dx}=0$$ inside the domain of integration $$(x=\sqrt{\frac{\pi}{2}})$$ there is no issue because we don't have to divide by this expression to make all the $$x$$s cancel. Anyway, I'm curious for further explanation and to know if there are any references which carefully explain subtleties such as this for integration by substitution.

• The change of variable transform should be a diffeomorphism, see here. In the framework of $\mathbb R$, that is to say, the $x\mapsto u$ map should be monotone.
– Feng
Commented Sep 7, 2023 at 3:19
• As the answer below points out, it's the $\pm$ symbol. You haven't actually fully worked out the substitution, because $\pm\sqrt{1+4u}$ isn't a function of $u$. Commented Sep 7, 2023 at 4:41
• @Feng : It doesn't have to be a diffeomorphism in the $1$-dimensional case (or even in $n$ dimensions if you keep track of orientation, but that's harder for $n>1$ and the link you gave doesn't do that). Notice that the theorem in Alex's answer doesn't need $g$ to be a diffeomorphism, nor does the first integral in the question. But of course it does need to be a well-defined (and differentiable) function, which is where the second integral in the question fails. Commented Sep 7, 2023 at 5:56
• @TobyBartels You're right! Thank you for your patient explanation. :-)
– Feng
Commented Sep 7, 2023 at 6:10
• @TobyBartels Where can I find proof for change of variable in which substitution does not have to be diffeomorphism? Commented Sep 9, 2023 at 5:42

Formally, substitution says that if $$g$$ is differentiable on an interval, and $$f$$ is continuous on the image interval of $$g$$, then

$$\int_a^b f(g(x)) g'(x) \, dx = \int_{g(a)}^{g(b)} f(u) \, du.$$

In our case, when we try to write the simple yet problematic integral in the form required by the left-hand side, we get

$$\int_0^1 \, dx = \int_0^1 \frac1{2x-1}(2x-1)\, dx = \int_0^1 \, \frac1{\pm\sqrt{1+4(x^2 -x)}}(2x-1) \, dx,$$

but the sign ambiguity tells us that we must proceed more carefully (or else what single $$f$$ do we choose?). Indeed $$2x - 1 = \sqrt{1+4(x^2-x)}$$ when $$x > 1/2$$, whereas $$2x - 1 = -\sqrt{1+4(x^2-x)}$$ when $$x < 1/2$$. So really we should have written

$$\int_0^{1/2} \, \frac1{-\sqrt{1+4(x^2 -x)}}(2x-1) \, dx + \int_{1/2}^{1} \, \frac1{\sqrt{1+4(x^2 -x)}}(2x-1) \, dx,$$ or via $$u = g(x)$$

$$\int_0^{-1/4} \, \frac1{-\sqrt{1+4u}} \, du + \int_{-1/4}^{0} \, \frac1{\sqrt{1+4u}} \, du = \frac12 + \frac12 = 1,$$