The integral \(\int \frac{1}{x^2 + 1} \, dx\) is a known form. The general form \(\frac{1}{x^2 + a^2}\) integrates to \(\frac{1}{a} \tan^{-1}\left(\frac{x}{a}\right) + C\). With \(a = 1\), the integral is:\[\int \frac{1}{x^2 + 1} \, dx = \tan^{-1}x + C\]Alternatively, employ substitution: set \(x = \tan \theta\), which implies \(dx = \sec^2 \theta \, d\theta\). The integral transforms to:\[\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\]Therefore, option (2) is validated.