1. **State the problem:** We need to find the integral $$\int (x \tan x + 1)^2 \, dx$$.
2. **Use the hint and expand the integrand:**
$$(x \tan x + 1)^2 = x^2 \tan^2 x + 2x \tan x + 1$$
3. **Rewrite using the identity:**
$$\tan^2 x = \sec^2 x - 1$$
So,
$$x^2 \tan^2 x = x^2 (\sec^2 x - 1) = x^2 \sec^2 x - x^2$$
4. **Rewrite the integral:**
$$\int (x \tan x + 1)^2 \, dx = \int (x^2 \sec^2 x - x^2 + 2x \tan x + 1) \, dx$$
5. **Split the integral:**
$$= \int x^2 \sec^2 x \, dx - \int x^2 \, dx + 2 \int x \tan x \, dx + \int 1 \, dx$$
6. **Integrate the simpler terms:**
$$\int x^2 \, dx = \frac{x^3}{3}$$
$$\int 1 \, dx = x$$
7. **Focus on the integral $$\int x^2 \sec^2 x \, dx$$:**
Use integration by parts with
$$u = x^2, \quad dv = \sec^2 x \, dx$$
Then,
$$du = 2x \, dx, \quad v = \tan x$$
So,
$$\int x^2 \sec^2 x \, dx = x^2 \tan x - \int 2x \tan x \, dx$$
8. **Notice the integral $$\int 2x \tan x \, dx$$ appears again.**
Let
$$I = \int x \tan x \, dx$$
Use integration by parts again:
$$u = x, dv = \tan x \, dx$$
Then,
$$du = dx, v = -\ln |\cos x|$$
So,
$$I = -x \ln |\cos x| + \int \ln |\cos x| \, dx$$
9. **Putting it all together:**
$$\int x^2 \sec^2 x \, dx = x^2 \tan x - 2I$$
10. **Rewrite the original integral:**
$$\int (x \tan x + 1)^2 \, dx = (x^2 \tan x - 2I) - \frac{x^3}{3} + 2I + x + C$$
11. **Simplify by canceling $$-2I$$ and $$+2I$$:**
$$= x^2 \tan x - \frac{x^3}{3} + x + C$$
**Final answer:**
$$\boxed{\int (x \tan x + 1)^2 \, dx = x^2 \tan x - \frac{x^3}{3} + x + C}$$
Integral Tanx Square B57089
Step-by-step solutions with LaTeX - clean, fast, and student-friendly.