The integral \(\int \frac{1}{x^2 + 1} \, dx\) is a standard form. Recognize that \(\frac{1}{x^2 + a^2}\) integrates to \(\frac{1}{a} \tan^{-1}\left(\frac{x}{a}\right) + C\). Here, \(a = 1\), so:
\[
\int \frac{1}{x^2 + 1} \, dx = \tan^{-1}x + C
\]
Alternatively, use substitution: let \(x = \tan \theta\), then \(dx = \sec^2 \theta \, d\theta\), and the integral becomes:
\[
\int \frac{\sec^2 \theta}{\tan^2 \theta + 1} \, d\theta = \int \frac{\sec^2 \theta}{\sec^2 \theta} \, d\theta = \int 1 \, d\theta = \theta + C = \tan^{-1}x + C
\]
Thus, option (2) is correct.