I want to solve the following integral:
$$\int_0^\pi \sqrt{1+\sin x} \, dx$$
I want to do this with the substitution:
$$u=\sin x$$
so that:
$$du=\cos x\,dx=\sqrt{1-\sin^2x}\,dx = \sqrt{1-u^2} \, dx$$
$$dx = \frac{du}{1-u^2}$$
$$u(0) = 0, \quad u(\pi/2)=1, \quad u(\pi)=0$$
$$\int\sqrt{1+\sin x} \, dx = \int\frac{1}{\sqrt{1-u}} \, du = -2\sqrt{1-u}$$
So since $u$ isn't defined for 1 (corresponding $x$ is $\pi/2$), I split the integration to ($0, \pi/2$) and ($\pi/2, \pi$) However when I assign the substitution I get:
$$\int_0^1 \frac{1}{\sqrt{1-u}} \, du + \int_1^0 \frac{1}{\sqrt{1-u}} \, du = 2-2 = 0$$
But the result should be $4.$ It seems like I should flip the sign here for some reason but I can't figure it out, help would be appreciated.