Consider ∫x2−1x+2dx. Substitution fails (numerator isn't the derivative of the denominator) and by-parts goes nowhere. Instead, factor and split:
(x−1)(x+1)x+2=x−1A+x+1BSolving A(x+1)+B(x−1)=x+2 gives A=23, B=−21, so the integral is 23ln∣x−1∣−21ln∣x+1∣+C. This works whenever the denominator factors into distinct linear terms.