To solve the integral
\[
\int \frac{x^3 + 3}{(x + 1)(x^2 + 1)} \, dx,
\]
we can break it down into simpler parts. Here’s a step-by-step solution:
### Step 1: Simplify the integrand
We start by rewriting the numerator \(x^3 + 3\) in a way that can be easily integrated. We can express \(x^3 + 3\) as:
\[
x^3 + 3 = (x^3 + 1) + 2 = (x + 1)(x^2 - x + 1) + 2.
\]
Thus, we can rewrite the integral as:
\[
\int \frac{(x + 1)(x^2 - x + 1) + 2}{(x + 1)(x^2 + 1)} \, dx.
\]
### Step 2: Split the integral
Now, we can split the integral into two parts:
\[
\int \frac{(x + 1)(x^2 - x + 1)}{(x + 1)(x^2 + 1)} \, dx + \int \frac{2}{(x + 1)(x^2 + 1)} \, dx.
\]
The first part simplifies to:
\[
\int \frac{x^2 - x + 1}{x^2 + 1} \, dx.
\]
### Step 3: Integrate the first part
For the first integral, we can separate it further:
\[
\int \left(1 - \frac{x}{x^2 + 1} + \frac{1}{x^2 + 1}\right) \, dx.
\]
This gives us three separate integrals:
\[
\int 1 \, dx - \int \frac{x}{x^2 + 1} \, dx + \int \frac{1}{x^2 + 1} \, dx.
\]
Calculating these integrals:
1. \(\int 1 \, dx = x\).
2. For \(\int \frac{x}{x^2 + 1} \, dx\), we can use the substitution \(u = x^2 + 1\), \(du = 2x \, dx\), which leads to \(\frac{1}{2} \ln|x^2 + 1|\).
3. \(\int \frac{1}{x^2 + 1} \, dx = \tan^{-1}(x)\).
So, combining these results, we have:
\[
x - \frac{1}{2} \ln|x^2 + 1| + \tan^{-1}(x).
\]
### Step 4: Integrate the second part
Now we need to integrate the second part:
\[
\int \frac{2}{(x + 1)(x^2 + 1)} \, dx.
\]
We can use partial fraction decomposition:
\[
\frac{2}{(x + 1)(x^2 + 1)} = \frac{A}{x + 1} + \frac{Bx + C}{x^2 + 1}.
\]
Multiplying through by the denominator \((x + 1)(x^2 + 1)\) and equating coefficients gives us a system of equations to solve for \(A\), \(B\), and \(C\). After solving, we find:
\[
A = 2, \quad B = 0, \quad C = -2.
\]
Thus, we can rewrite the integral as:
\[
\int \left(\frac{2}{x + 1} - \frac{2}{x^2 + 1}\right) \, dx.
\]
Calculating these integrals:
1. \(\int \frac{2}{x + 1} \, dx = 2 \ln|x + 1|\).
2. \(\int \frac{2}{x^2 + 1} \, dx = 2 \tan^{-1}(x)\).
### Step 5: Combine all parts
Now we combine all the parts:
\[
x - \frac{1}{2} \ln|x^2 + 1| + \tan^{-1}(x) + 2 \ln|x + 1| - 2 \tan^{-1}(x) + C.
\]
This simplifies to:
\[
x - \frac{1}{2} \ln|x^2 + 1| - \tan^{-1}(x) + 2 \ln|x + 1| + C.
\]
### Final Answer
Thus, the final result of the integral is:
\[
\int \frac{x^3 + 3}{(x + 1)(x^2 + 1)} \, dx = x - \frac{1}{2} \ln|x^2 + 1| - \tan^{-1}(x) + 2 \ln|x + 1| + C.
\]