Partial Fraction problem solution deviates from the Rule Question:
Compute $\displaystyle \int\frac{x^2+1}{(x^2+2)(x+1)} \, dx$
My Approach:
As per my knowledge this integral can be divided in partial Fraction of form $\dfrac{Ax+B}{x^2+px+q}$ and then do the following as per to integrate it.
Solution:
Taking $\dfrac{x^2+1}{(x^2+2)(x+1)}=\dfrac{Ax^2+Bx+C}{x^2+2}+\dfrac{D}{x+1}$
Rule given: Denominator g(x) contains quadratic tractor (may not be factorisable).
To each non-repeated quadratic factor of the form $x^2+px+q$(or $x^2+q$, $q$ not equal to $0$), there
Should be a partial Fraction of the form $Ax+B/(x^2+px+q)$.
My problem:
I can't understand why the solution provided deviates from the rule that I have studied to solve these kind of problems.
Book:
ISC MATHEMATICS XII
Publishers:
Kalyani
 A: you must write $$\frac{x^2+1}{(x^2+2)(x+1)}=\frac{Ax+B}{x^2+2}+\frac{C}{x+1}$$
A: From what I understand, the solution in your book points that the fraction can be writeen as
$$ \frac{x^{2}+1}{(x^{2}+2)(x+1)} = \frac{Ax^{2}+Bx+C}{x^{2}+2}  + \frac{D}{x+1} $$
$$  = \frac{(Ax^{2}+Bx+C)(x+1) + D(x^{2}+2)}{(x^{2}+2)(x+1)} $$
Of course it can, you just need to find the appropriate constants :
$$ Ax^{3} + (A+B+ D)x^{2} + (B+C)x + (C+2D)  = x^{2}+1  $$
$$ \implies A = 0, \:\: A+B+D = 1, \:\: B+C = 0, \:\: C+2D=1$$
Now, actually, from this step, we can already see that $A=0$is a necessity, so the partial fractions must be of the form
$$\frac{Bx+C}{x^{2}+2}  + \frac{D}{x+1} $$
which is the rule that you already know.
Both the solution and the rule are correct, its just that using the rule will be more efficient.
A: Dividing $x^2+1$ by $x^2+2$ yields $1$ as the quotient and $-1$ as the remainder, so we have
$$
\frac{x^2+1}{x^2+2} = 1 - \frac 1 {x^2+2}.
$$
So
\begin{align}
& \frac{x^2+1}{(x^2+2)(x+1)} = \frac 1 {x+1} - \frac 1 {(x^2+2)(x+1)} \\[15pt]
= {} & \frac 1 {x+1} + \frac{Ax+B}{x^2+2} + \frac{\text{some constant}}{x+1} \\[15pt]
= {} & \frac{Ax+B}{x^2+2} + \frac C {x+1}
\end{align}
Thus I would decompose this into partial fractions in a way consistent with your approach.
