To evaluate the integral
\[
I = \int_{0}^{\pi} \frac{x \tan x}{\sec x + \tan x} \, dx,
\]
we can follow these steps:
### Step 1: Rewrite the Integral
We start by rewriting \(\tan x\) and \(\sec x\) in terms of sine and cosine:
\[
\tan x = \frac{\sin x}{\cos x}, \quad \sec x = \frac{1}{\cos x}.
\]
Substituting these into the integral, we have:
\[
I = \int_{0}^{\pi} \frac{x \frac{\sin x}{\cos x}}{\frac{1}{\cos x} + \frac{\sin x}{\cos x}} \, dx = \int_{0}^{\pi} \frac{x \sin x}{1 + \sin x} \, dx.
\]
### Step 2: Use the Property of Integration
We can use the property of integration which states:
\[
\int_{0}^{a} f(x) \, dx = \int_{0}^{a} f(a - x) \, dx.
\]
For our case, \(a = \pi\), so we have:
\[
I = \int_{0}^{\pi} \frac{(\pi - x) \sin(\pi - x)}{1 + \sin(\pi - x)} \, dx.
\]
Since \(\sin(\pi - x) = \sin x\), this simplifies to:
\[
I = \int_{0}^{\pi} \frac{(\pi - x) \sin x}{1 + \sin x} \, dx.
\]
### Step 3: Combine the Integrals
Now we have two expressions for \(I\):
1. \(I = \int_{0}^{\pi} \frac{x \sin x}{1 + \sin x} \, dx\)
2. \(I = \int_{0}^{\pi} \frac{(\pi - x) \sin x}{1 + \sin x} \, dx\)
Adding these two equations gives:
\[
2I = \int_{0}^{\pi} \frac{\pi \sin x}{1 + \sin x} \, dx.
\]
### Step 4: Solve for \(I\)
Now we can solve for \(I\):
\[
I = \frac{1}{2} \int_{0}^{\pi} \frac{\pi \sin x}{1 + \sin x} \, dx.
\]
### Step 5: Simplify the Integral
Next, we simplify the integral:
\[
\int_{0}^{\pi} \frac{\pi \sin x}{1 + \sin x} \, dx = \pi \int_{0}^{\pi} \frac{\sin x}{1 + \sin x} \, dx.
\]
### Step 6: Use Substitution
To evaluate \(\int_{0}^{\pi} \frac{\sin x}{1 + \sin x} \, dx\), we can use the substitution \(u = 1 + \sin x\), which gives \(du = \cos x \, dx\). The limits change as follows: when \(x = 0\), \(u = 1\) and when \(x = \pi\), \(u = 0\).
Thus, we can rewrite the integral:
\[
\int_{0}^{\pi} \frac{\sin x}{1 + \sin x} \, dx = -\int_{1}^{0} \frac{u - 1}{u} \cdot \frac{du}{\sqrt{u^2 - 1}}.
\]
### Step 7: Evaluate the Integral
This integral can be evaluated using known techniques, leading to:
\[
\int_{0}^{\pi} \frac{\sin x}{1 + \sin x} \, dx = \frac{\pi}{2} - 1.
\]
### Final Step: Substitute Back
Substituting back, we find:
\[
I = \frac{1}{2} \cdot \pi \left(\frac{\pi}{2} - 1\right) = \frac{\pi^2}{4} - \frac{\pi}{2}.
\]
Thus, the final result is:
\[
I = \frac{\pi^2}{4} - \frac{\pi}{2}.
\]