To solve the differential equation \((1 + x^2) dy + 2xy dx = \cot x \, dx\), we will follow these steps:
### Step 1: Rearranging the Equation
We start by rearranging the given equation:
\[
(1 + x^2) dy = \cot x \, dx - 2xy \, dx
\]
This can be rewritten as:
\[
(1 + x^2) dy + 2xy \, dx = \cot x \, dx
\]
### Step 2: Dividing by \(1 + x^2\)
Next, we divide the entire equation by \(1 + x^2\):
\[
dy + \frac{2xy}{1 + x^2} dx = \frac{\cot x}{1 + x^2} dx
\]
This simplifies to:
\[
dy + \frac{2xy}{1 + x^2} dx = \frac{\cot x}{1 + x^2} dx
\]
### Step 3: Identifying \(P\) and \(Q\)
From the rearranged equation, we can identify:
\[
P = \frac{2x}{1 + x^2}, \quad Q = \frac{\cot x}{1 + x^2}
\]
### Step 4: Finding the Integrating Factor
The integrating factor \(I\) is given by:
\[
I = e^{\int P \, dx}
\]
Calculating the integral:
\[
\int P \, dx = \int \frac{2x}{1 + x^2} \, dx
\]
Let \(t = 1 + x^2\), then \(dt = 2x \, dx\). Thus, the integral becomes:
\[
\int \frac{2x}{1 + x^2} \, dx = \int \frac{1}{t} \, dt = \ln |t| + C = \ln(1 + x^2) + C
\]
Therefore, the integrating factor is:
\[
I = e^{\ln(1 + x^2)} = 1 + x^2
\]
### Step 5: Multiplying the Equation by the Integrating Factor
Now we multiply the entire differential equation by the integrating factor:
\[
(1 + x^2) dy + 2xy \, dx = \cot x \, dx
\]
This simplifies to:
\[
(1 + x^2) dy + 2xy \, dx = \cot x \, dx
\]
### Step 6: Solving the Equation
We can now write the left-hand side as the derivative of a product:
\[
\frac{d}{dx}[(1 + x^2)y] = \cot x
\]
Integrating both sides with respect to \(x\):
\[
(1 + x^2)y = \int \cot x \, dx
\]
The integral of \(\cot x\) is:
\[
\int \cot x \, dx = \ln |\sin x| + C
\]
Thus, we have:
\[
(1 + x^2)y = \ln |\sin x| + C
\]
### Step 7: Final Solution
Solving for \(y\):
\[
y = \frac{\ln |\sin x| + C}{1 + x^2}
\]
### Summary
The solution to the differential equation is:
\[
y = \frac{\ln |\sin x| + C}{1 + x^2}
\]