Problem: Expand $$\frac {2x^2 + x}{(x+1)(x^2+1)}$$ using partial fraction decomposition.
I wrote the following $$\frac A {x+1} + \frac B {x^2 + 1} = \frac {x(2x+1)}{(x+1)(x^2+1)} \\ A(x^2+1) + B(x+1) = x(2x + 1).$$ Plugging $x = 0$, I get $$A + B = 0.$$ Plugging in $x = 1$, I get $$2(A+B) = 3,$$ a contradiction. Where is my mistake? And how should I solve this?
Also: I could separate the initial expression into $$\frac {2x^2}{(x+1)(x^2+1)} + \frac {x}{(x+1)(x^2+1)}$$ but am not sure if that would help (and, if it would, how should I know to do this?).
Your error is in assuming that the rational function admits a decomposition of the form $$\frac{A}{x+1} + \frac{B}{x^2+1}.$$ Instead, the decomposition would have the form $$\frac{A}{x+1} + \frac{B \color{red}{x + C}}{x^2 + 1}$$ because the denominator of the second term has degree $2$. If you now use this form, you will find $$A(x^2 + 1) + (Bx + C)(x+1) = (A+B)x^2 + (B+C)x + (A+C) = 2x^2 + x$$ hence we require $$C = -A, \quad B = -C + 1, \quad A = -B + 2.$$ Substituting the first equation into the second, $B = A + 1$, and now substituting this into the third, $$A = -(A+1) + 2 = -A + 1.$$ Therefore, $$A = \frac{1}{2}, \quad B = \frac{3}{2}, \quad C = -\frac{1}{2},$$ and $$\frac{2x^2 + 2}{(x+1)(x^2+1)} = \frac{1}{2}\left( \frac{1}{x+1} + \frac{3x-1}{x^2+1}\right).$$