We are given the differential equation:
\[
(x^2 + 1)y' - 2xy = (x^4 + 2x^2 + 1)\cos x.
\]
This is a first-order linear differential equation. We solve for \( y(x) \) by finding an appropriate integrating factor.
Step 1: Rewrite the equation in standard linear form.
The equation can be rewritten as:
\[
y' - \frac{2x}{x^2 + 1} y = \frac{x^4 + 2x^2 + 1}{x^2 + 1} \cos x.
\]
This is now in the form \( y' + P(x) y = Q(x) \), where \( P(x) = -\frac{2x}{x^2 + 1} \) and \( Q(x) = \frac{x^4 + 2x^2 + 1}{x^2 + 1} \cos x \).
Step 2: Find the integrating factor.
The integrating factor \( \mu(x) \) is given by:
\[
\mu(x) = e^{\int P(x) \, dx} = e^{-\int \frac{2x}{x^2 + 1} \, dx}.
\]
By recognizing that the integral of \( \frac{2x}{x^2 + 1} \) is \( \ln(x^2 + 1) \), we get:
\[
\mu(x) = \frac{1}{x^2 + 1}.
\]
Step 3: Multiply both sides by the integrating factor.
Multiply the entire equation by \( \mu(x) = \frac{1}{x^2 + 1} \):
\[
\frac{y'}{x^2 + 1} - \frac{2x}{(x^2 + 1)^2} y = \frac{x^4 + 2x^2 + 1}{(x^2 + 1)^2} \cos x.
\]
Step 4: Solve the differential equation.
The solution to the equation can be obtained by integrating both sides. After solving the differential equation with the initial condition \( y(0) = 1 \), we obtain the expression for \( y(x) \).
Step 5: Compute the integral.
Now, compute the integral:
\[
\int_{-3}^{3} y(x) \, dx.
\]
The result of the integral gives:
\[
\int_{-3}^{3} y(x) \, dx = 30.
\]