Rewrite the equation:
\[
(1+x^2) \frac{dy}{dx} + y = \tan^{-1} x \implies \frac{dy}{dx} + \frac{y}{1+x^2} = \frac{\tan^{-1} x}{1+x^2}.
\]
This is a linear first-order differential equation of the form:
\[
\frac{dy}{dx} + P(x) y = Q(x),
\]
where
\[
P(x) = \frac{1}{1+x^2}, \quad Q(x) = \frac{\tan^{-1} x}{1+x^2}.
\]
The integrating factor (IF) is:
\[
\mu(x) = e^{\int P(x) dx} = e^{\int \frac{1}{1+x^2} dx} = e^{\tan^{-1} x}.
\]
Multiply both sides by the integrating factor:
\[
e^{\tan^{-1} x} \frac{dy}{dx} + \frac{e^{\tan^{-1} x}}{1+x^2} y = \frac{\tan^{-1} x}{1+x^2} e^{\tan^{-1} x}.
\]
Left side is:
\[
\frac{d}{dx} \left( y \, e^{\tan^{-1} x} \right) = \frac{\tan^{-1} x}{1+x^2} e^{\tan^{-1} x}.
\]
Integrate both sides:
\[
y \, e^{\tan^{-1} x} = \int \frac{\tan^{-1} x}{1+x^2} e^{\tan^{-1} x} \, dx + C.
\]
Let
\[
t = \tan^{-1} x \implies dt = \frac{1}{1+x^2} dx.
\]
So,
\[
\int \frac{\tan^{-1} x}{1+x^2} e^{\tan^{-1} x} dx = \int t e^{t} dt.
\]
Integrate by parts:
\[
\int t e^{t} dt = t e^{t} - \int e^{t} dt = t e^{t} - e^{t} + C = e^{t} (t - 1) + C.
\]
Therefore,
\[
y \, e^{\tan^{-1} x} = e^{\tan^{-1} x} (\tan^{-1} x - 1) + C,
\]
and
\[
\boxed{
y = \tan^{-1} x - 1 + C e^{-\tan^{-1} x}.
}
\]