Integration by partial fractions; how and why does it work? Could someone take me through the steps of decomposing 
$$\frac{2x^2+11x}{x^2+11x+30}$$
into partial fractions? 
More generally, how does one use partial fractions to compute integrals
$$\int\frac{P(x)}{Q(x)}\,dx$$
of rational functions ($P(x)$ and $Q(x)$ are polynomials) ?

This question is asked in an effort to cut down on duplicates. See Coping with *abstract* duplicate questions.
Also see List of Generalizations of Common Questions.
 A: I can't really TeX out polynomial long division in the normal sense, but essentially you want to solve 
$$
2x^2+11x=g(x)\cdot (x^2+11x+30)+r(x)
$$
by finding polynomials $g(x)$ and $r(x)$ such that $\deg(r)=0$ or $\deg(r)<\deg(x^2+11x+30)$.
You want to get the leading terms to match on both sides, right? So the leading term of $g(x)$ should be $2$. 
This is the constant term of the polynomial, so you've reached the end of the line in a sense. 
So 
$$
2x^2+11x=2\cdot (x^2+11x+30)+r(x)
$$
which implies
$$
r(x)=2x^2+11x-2\cdot (x^2+11x+30)=-11x-60.
$$
It follows that 
$$
\frac{2x^2+11x}{x^2+11x+30}=2+\frac{-11x-60}{x^2+11x+30}.
$$
You can check that 
$$
\frac{-11x-60}{x^2+11x+30}=-\frac{6}{x+6}-\frac{5}{x+5}.
$$
To actually get the remainder in that desired form, you could use the method of partial fractions to split the your remainder with quadratic denominator into a sum of terms with linear denominators. I can expand more on that if you're not familiar with it. It also may be quite helpful to follow the nice example given on wikipedia.
A: Here are some formal aspects of the delightful answer ( by Arturo Magidin ) above.
Let $ f(x), g(x) $ be polynomials ( $ g \neq 0 $ ). Our goal now is to integrate $ \frac{f}{g} $.
Dividing $ f $ by $ g $ gives that $ f = qg + r $ with $ \deg(r) < \deg(g) $, so $ \frac{f}{g} $ is a polynomial $ q $ plus a proper fraction $ \frac{r}{g} $ [ We'll call a  fraction $ \frac{p}{q} $ of polynomials  "proper" if $ \deg{p} < \deg{q} $ ]. Since the $ q, r $ here are unique, we'll call $ q $ the "polynomial part" and $ \frac{r}{g} $ the "proper fraction part" of $ \frac{f}{g} $.
Now we need only figure out how to integrate proper fractions, so let's take $ \deg(f) < \deg(g) $ to begin with.
$ g $ can be broken into a product consisting of linear factors, and quadratic factors with negative discriminant [ Proved here, for instance ]. Also, any proper fraction $ \displaystyle \frac{f}{g_1 \ldots g_k} $ where $ g_i $s are mutually coprime can be written as a sum of proper fractions with denominators $ g_1, \ldots, g_k $ [ Let's show it for $ k = 2 $, the general case follows by induction. Since $ g_1, g_2 $ are coprime, by Euclidean algorithm $ g_1 u_1 + g_2 u_2 = 1 $ for some polynomials $ u_1, u_2 $. Now $ \displaystyle \frac{f u_1}{g_2} + \frac{f u_2}{g_1} = \frac{f}{g_1 g_2} $, and since right hand side is proper the polynomial parts of $ \displaystyle \frac{f u_1}{g_2}, \frac{f u_2}{g_1} $ sum up to $ 0 $. So ( proper fraction part of $ f u_1 / g_2 $ ) + ( proper fraction part of $ f u_2 / g_1 $ ) = $ f / g_1 g_2 $ , done. ]
So $ \displaystyle \frac{f}{g} $ breaks into a sum of proper fractions of the form $ \displaystyle \frac{s(x)}{t(x) ^l} $ and $ \displaystyle \frac{p(x)}{h(x) ^k} $, where the $ t(x) $s are linear polynomials and $ h(x) $s are negative discriminant quadratics .
The terms here can be broken down further. Any proper fraction of the form $ \displaystyle \frac{f}{g^k} $ is a sum of proper fractions, with denominators $ g, \ldots, g^k $ and numerators having lower degree than $ g $ ( The $ f, g $ here are separate from the original problem. Notation repeated to try keep things more readable ). This is because : Division gives $ f = qg + r $ with $ \deg(r) < \deg(g) $, so $ \displaystyle \frac{f}{g^k} = \frac{q}{g^{k-1}} + \frac{r}{g^k} $. All the terms here are proper and $ \deg(r) < \deg(g) $. Now continuing onto $ \displaystyle \frac{q}{g^{k-1}} $, we're done.
So our original proper fraction $ \displaystyle \frac{f}{g} $ is a sum of proper fractions, of the form $ \displaystyle \frac{m}{(x+p)^l} $, and of the form $ \displaystyle \frac{ax+b}{(x^2 + cx + d)^k} $ where $ x^2 + cx + d $ has negative discriminant.
Proper fractions of the form $ \displaystyle \frac{m}{(x+p)^l} $ are easily integrated, for instance by substituting $ u = x + p $.
So finally, the problem is reduced to integrating fractions of the form $ \displaystyle \frac{ax+b}{(x^2 + cx + d)^k} $ where $ x^2 + cx + d $ has negative discriminant. Writing $ x^2 + cx + d $ as $ \displaystyle (x + \frac{c}{2})^2 + (d - \frac{c^2}{4}) $ and substituting $ u = x + \frac{c}{2} $ makes the integral take the form $ \displaystyle \int \frac{Au + B}{(u^2 + C^2)^k} du $. We can integrate the $ \displaystyle \frac{Au}{(u^2 + C^2)^k} $ part by substituting $ v = u^2 + C^2 $. And the $ \displaystyle \frac{B}{(u^2 + C^2)^k} $ part, as mentioned in the above answer, can be handled using integration by parts.
