Question: ∫ \frac{x^4 + 1}{x^3 - x^2 + x - 1} \, dx
1. **State the problem:** We want to find the integral $$\int \frac{x^4 + 1}{x^3 - x^2 + x - 1} \, dx.$$\n\n2. **Analyze the integrand:** The numerator is a polynomial of degree 4 and the denominator is a polynomial of degree 3. Since the degree of the numerator is higher, we first perform polynomial division.\n\n3. **Polynomial division:** Divide $$x^4 + 1$$ by $$x^3 - x^2 + x - 1$$.\n\n- Leading term division: $$\frac{x^4}{x^3} = x$$.\n- Multiply divisor by $$x$$: $$x(x^3 - x^2 + x - 1) = x^4 - x^3 + x^2 - x$$.\n- Subtract: $$\left(x^4 + 1\right) - \left(x^4 - x^3 + x^2 - x\right) = x^3 - x^2 + x + 1.$$\n\n4. **Rewrite the integral:**\n$$\int \frac{x^4 + 1}{x^3 - x^2 + x - 1} \, dx = \int \left(x + \frac{x^3 - x^2 + x + 1}{x^3 - x^2 + x - 1}\right) dx.$$\n\n5. **Simplify the fraction:** Let $$R(x) = \frac{x^3 - x^2 + x + 1}{x^3 - x^2 + x - 1}.$$\n\n6. **Partial fraction or simplification:** Notice numerator and denominator differ by 2 in the constant term. Try to write numerator as denominator plus 2: $$x^3 - x^2 + x + 1 = (x^3 - x^2 + x - 1) + 2.$$\n\nSo, $$R(x) = \frac{(x^3 - x^2 + x - 1) + 2}{x^3 - x^2 + x - 1} = 1 + \frac{2}{x^3 - x^2 + x - 1}.$$\n\n7. **Rewrite integral:**\n$$\int \left(x + 1 + \frac{2}{x^3 - x^2 + x - 1}\right) dx = \int (x + 1) dx + 2 \int \frac{1}{x^3 - x^2 + x - 1} dx.$$\n\n8. **Integrate the polynomial part:**\n$$\int (x + 1) dx = \frac{x^2}{2} + x + C.$$\n\n9. **Factor denominator:**\n$$x^3 - x^2 + x - 1 = (x - 1)(x^2 + 1).$$\n\n10. **Partial fraction decomposition:**\n$$\frac{1}{(x - 1)(x^2 + 1)} = \frac{A}{x - 1} + \frac{Bx + C}{x^2 + 1}.$$\n\nMultiply both sides by denominator:\n$$1 = A(x^2 + 1) + (Bx + C)(x - 1).$$\n\nExpand right side:\n$$1 = A x^2 + A + B x^2 - B x + C x - C.$$\n\nGroup terms:\n$$1 = (A + B) x^2 + (-B + C) x + (A - C).$$\n\nEquate coefficients with left side (which is 1):\n- Coefficient of $$x^2$$: $$A + B = 0$$\n- Coefficient of $$x$$: $$-B + C = 0$$\n- Constant term: $$A - C = 1$$\n\n11. **Solve system:**\nFrom $$A + B = 0$$, $$B = -A$$.\nFrom $$-B + C = 0$$, $$C = B = -A$$.\nFrom $$A - C = 1$$, substitute $$C = -A$$:\n$$A - (-A) = 1 \Rightarrow 2A = 1 \Rightarrow A = \frac{1}{2}.$$\nThen $$B = -\frac{1}{2}$$ and $$C = -\frac{1}{2}.$$\n\n12. **Rewrite integral:**\n$$2 \int \frac{1}{(x - 1)(x^2 + 1)} dx = 2 \int \left( \frac{1/2}{x - 1} + \frac{-\frac{1}{2} x - \frac{1}{2}}{x^2 + 1} \right) dx = \int \frac{1}{x - 1} dx - \int \frac{x + 1}{x^2 + 1} dx.$$\n\n13. **Integrate each term:**\n- $$\int \frac{1}{x - 1} dx = \ln|x - 1| + C.$$\n- $$\int \frac{x}{x^2 + 1} dx$$: Use substitution $$u = x^2 + 1$$, $$du = 2x dx$$, so $$\int \frac{x}{x^2 + 1} dx = \frac{1}{2} \ln(x^2 + 1) + C.$$\n- $$\int \frac{1}{x^2 + 1} dx = \arctan x + C.$$\n\n14. **Combine:**\n$$- \int \frac{x + 1}{x^2 + 1} dx = - \int \frac{x}{x^2 + 1} dx - \int \frac{1}{x^2 + 1} dx = - \frac{1}{2} \ln(x^2 + 1) - \arctan x + C.$$\n\n15. **Final answer:**\n$$\int \frac{x^4 + 1}{x^3 - x^2 + x - 1} dx = \frac{x^2}{2} + x + \ln|x - 1| - \frac{1}{2} \ln(x^2 + 1) - \arctan x + C.$$