Solution:
Key idea: First simplify the integrand to 1+sinxxsinx.
Then use the property ∫0af(x)dx=∫0af(a−x)dx, taking a=π.
Since sin(π−x)=sinx, adding the two forms removes the factor x.
Step 1 — Simplify the integrand.
We write tanx=cosxsinx and secx=cosx1, then multiply the top and bottom by cosx.
secx+tanxxtanx=1+sinxxsinx
So the integral becomes the following, and we call it I.
I=∫0π1+sinxxsinxdx...(1)
Step 2 — Replace x by π − x.
Since sin(π−x)=sinx, only the factor x changes, to π−x.
I=∫0π1+sinx(π−x)sinxdx...(2)
Step 3 — Add (1) and (2).
The factors x and π−x add up to π, a constant that comes out of the integral.
2I=π∫0π1+sinxsinxdx
Step 4 — Split the fraction.
We write sinx=(1+sinx)−1 in the numerator.
1+sinxsinx=1−1+sinx1
2I=π[∫0π1dx−∫0π1+sinxdx]
Step 5 — Integrate 1/(1 + sin x).
We multiply the top and bottom by 1−sinx, so the denominator becomes 1−sin2x=cos2x.
1+sinx1=cos2x1−sinx
1+sinx1=sec2x−secxtanx
An antiderivative is tanx−secx. We write it as one fraction, which stays finite at x=2π as well.
tanx−secx=cosxsinx−1
tanx−secx=−1+sinxcosx
We put in the two limits, using cosπ=−1, cos0=1, sinπ=0 and sin0=0.
−1+sinπcosπ=1
−1+sin0cos0=−1
∫0π1+sinxdx=1−(−1)
∫0π1+sinxdx=2
Step 6 — Find I.
We put ∫0π1dx=π and the result of Step 5 into Step 4.
2I=π(π−2)
I=2π(π−2)
I=2π2−π
Note: The printed integrand is not defined at x=2π, where tanx and secx do not exist. Its simplified form 1+sinxxsinx is continuous on the whole interval, so the integral is found from that form.
Therefore, ∫0πsecx+tanxxtanxdx=2π(π−2).