<s>[INST] Partial fractions $\int \frac{(3x^2 - 4x + 5)\,dx}{(x-1)(x^2+2)}$ $$\int \frac{(3x^2 - 4x + 5 )\, dx}{(x-1)(x^2+2)}$$
I am going to use undetermined coefficients since it seems straightforward, no wacky matrices or tables to memorize.
 $$\int \frac{(3x^2 - 4x + 5 )\, dx}{(x-1)(x^2+2)} \quad = \quad\int \left(\frac {A}{x} + \frac{B}{(x-1)^2}+\frac{C}{(x-1)}+D\right)\,dx$$
I get $$A(x^3 - 3x^2 + 3x - 1) +B(x^3 - 2x^2 + x) + C(x^2 - x) + Dx$$
This gives me the sets of
$$\begin{align} 
A + B & = 0\\ \\ 
-3A + -2B + C & = 0 \\ \\
3A + B - C + D & = 0 \\ \\
-A &= 0
\end{align}$$
This is obviously wrong because A and B are now 0. What do I do?
 [/INST] Before moving to partial fractions, it's useful to separate the denominator's derivative, which is $(3x^2-2x+2)$:
$$\begin{align}
\int\frac{3x^2-4x+5}{(x-1)(x^2+2)}\,dx
&=\int\frac{(3x^2-2x+2)+(-2x+3)}{(x-1)(x^2+2)}\,dx\\
&=\ln((x-1)(x^2+2))+\int\frac{-2x+3}{(x-1)(x^2+2)}\,dx\\
\end{align}$$
Now the remaining separation into partial fractions is easier because there's an extra zero in the system of equations. In fact the separation must be in the form:
$$\begin{align}
\ln((x-1)(x^2+2))+\int\left(\frac{A}{x-1}+\frac{-Ax+B}{x^2+2}\right)\,dx\\
\end{align}$$
to make the $x^2$ terms disappear from the numerator. Now the system to solve is $$\left\{\begin{array}{rcl}A+B&=&-2\\2A-B&=&3\end{array}\right.$$ "Adding" equations reveals that $A=1/3$. From there, we deduce $B=-7/3$. So we have $$\begin{align}
\ln((x-1)(x^2+2))+\frac{1}{3}\int\left(\frac{1}{x-1}+\frac{-x+7}{x^2+2}\right)\,dx\\
\end{align}$$
Again, I'd separate a derivative:
$$\begin{align}
\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)+\frac{1}{3}\int\frac{-x+7}{x^2+2}\,dx\\
=\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\int\frac{2x-14}{x^2+2}\,dx\\
=\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\ln(x^2+2)+\frac{1}{3}\int\frac{7}{x^2+2}\,dx\\
\end{align}$$ and the last integral can be handled via substituting $2u^2=x^2$:
$$\begin{align}
\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\ln(x^2+2)+\frac{1}{3}\int\frac{7}{x^2+2}\,dx\\
\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\ln(x^2+2)+\frac{1}{3}\int\frac{7}{2u^2+2}\,(\sqrt{2}\,du)\\
\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\ln(x^2+2)+\frac{7}{3\sqrt{2}}\arctan(u)+C\\
\ln((x-1)(x^2+2))+\frac{1}{3}\ln(x-1)-\frac{1}{6}\ln(x^2+2)+\frac{7}{3\sqrt{2}}\arctan(x/\sqrt{2})+C\\
\end{align}$$
</s>