By using the properties of definite integrals, evaluate $\int_0^{\pi}\frac{x}{1+\sin x}dx$ 
By using the properties of definite integrals, evaluate $\int_0^{\pi}\frac{x}{1+\sin x}dx$.

My attempt:
(Using the property $\int_0^{2a}f(x)dx=\int_0^a(f(x)+f(2a-x))dx$)
$$\int_0^{2\frac{\pi}{2}}\frac{x}{1+\sin x}dx=\int_0^{\frac{\pi}{2}}(\frac{x}{1+\sin x}+\frac{\pi-x}{1+\sin x})dx$$$$=\pi\int_0^{\frac{\pi}{2}}\frac1{1+\sin x}dx=\pi\int_0^{\frac{\pi}{2}}\frac{1-\sin x}{\cos^2x}dx$$$$=\pi\int_0^{\frac{\pi}{2}}(\sec^2x-\sec x\tan x)dx=\pi[\tan x-\sec x]_0^{\frac{\pi}{2}}$$
Now I am stuck. I understand there might be other ways of solving it, but what's wrong in my method? Why am I not getting the answer?
 A: Your final integral is an improper integral, so you do not evaluate the antiderivative you obtain at the endpoints, you take limits approaching the endpoints.
\begin{align*}
\lim_{x \rightarrow 0^+} (\tan x - \sec x) &= -1  \\
\lim_{x \rightarrow (\pi/2)^-} (\tan x - \sec x) &= 0  \text{.}
\end{align*}
So you obtain $\pi(0--1) = \pi$, which is the correct answer.  (The first limit is not actually necessary, since the antiderivative is continuous at $x = 0$.)
A: $1-\sin x=0$ for $x=\pi/2$ and so you're dividing by zero when multiply and divide by that expression.
A: Alternatively, I like to try to change sine to cosine and then tackle it by the properties of odd and even functions.
First of all,  I use the substitution $y=\dfrac{\pi}{2}-x,$ then
$$
\begin{aligned}
I &=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{\frac{\pi}{2}-y}{1+\cos y} d y \\
&=\frac{\pi}{2} \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{d y}{1+\cos y}-\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{y}{1+\cos y} d y \\
&=\frac{\pi}{2} \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{d y}{1+\cos y} \quad \text { (By the fact that } \frac{y}{1+\cos y} \textrm{ is odd.}) \\
&=\frac{\pi}{2} \int_{0}^{\frac{\pi}{2}} \sec ^{2} \frac{y}{2} d y \\
&=\pi\left[\tan \frac{y}{2}\right]_{0}^{\frac{\pi}{2}} \\
&=\pi
\end{aligned}
$$
:|D Wish you enjoy the proof!
