# Partial Fraction Decomposition, part 1
## Overview
**Partial fraction decomposition** is a method for dealing with the integrals of **rational functions**: ratios of polynomials.
Examples include
* $\displaystyle\int \displaystyle\frac{1}{x^2 + 4x + 3}$
* $\displaystyle\int \displaystyle\frac{x}{(x-1)^2(x+2)}$
## First Big Idea :bulb:
Parital Fraction Decomposition is like *getting a common denominator in reverse*.
**Examples:**
1. Using a common denominator, we see that: $$\displaystyle\frac{1}{x+1} + \displaystyle\frac{1}{x} = \displaystyle\frac{x}{x(x+1)} + \displaystyle\frac{x+1}{x(x+1)} = \displaystyle\frac{2x+1}{x(x+1)} = \displaystyle\frac{2x+1}{x^2 + x}$$
So if we saw $\displaystyle\int \displaystyle\frac{1}{x+1} + \displaystyle\frac{1}{x} \; dx$ , we could use the equivalence to rewrite $$\displaystyle\int \displaystyle\frac{2x+1}{x^2 + x} \; dx$$ as
$$\displaystyle\int \displaystyle\frac{1}{x+1} + \displaystyle\frac{1}{x} \; dx,$$ which is a more approachable integral.
2. We can also see $$\displaystyle\frac{1}{x+1} - \displaystyle\frac{1}{x} = \displaystyle\frac{x}{x(x+1)} - \displaystyle\frac{x+1}{x(x+1)} = \displaystyle\frac{-1}{x(x+1)}$$
If we had to look at the integral $\displaystyle\frac{-1}{x^2 + x}$, this might be very helpful!
## Second Big Idea :bulb:
**Review:** How to integrate things that look like this?
$$\displaystyle\int \displaystyle\frac{1}{x+2} \; dx $$
By using the substitution $u = x + 2$, we get
$$\displaystyle\int \displaystyle\frac{1}{x+2} \; dx = \ln\left( | x + 2 \right) + C$$
**Note:** In this document we will only be looking at examples where the denominator can be factored into **distinct linear factors**.
## Example
Let's look at $\displaystyle\int \displaystyle\frac{2x+1}{x^2 + x}$.

We can rewrite using the decomposition we saw earlier in this document.

But we were lucky here...we already knew how to split it up! What if we didn't?
---
**Example of Process with Repeated Linear Factors:**
For instance, let's look at
$\displaystyle\int \frac{x}{x^2 + 7x + 12} \; dx$. First, we use algebra to **factor**
$\displaystyle\int \frac{x}{x^2 + 7x + 12} \; dx = \displaystyle\int \frac{x}{(x+3)(x+4)} \; dx$
**Next Step:** Now we want to decompose $\displaystyle\frac{x}{(x+3)(x+4)}$ into $\displaystyle\frac{?}{x+3} + \displaystyle\frac{?}{x+4}$.
**Decomposition for Rational Function with Distinct Linear Factors**
**Step 1. Introduce The Form with Unknown Constants**
Rewrite $\displaystyle\frac{x}{(x+3)(x+4)} = \displaystyle\frac{A}{x+3} + \displaystyle\frac{B}{x+4}$, where we just need to find the $A$ and $B$.
**Step 2. Multiply to Cancel.** To find the $A$ and $B$, we multiply both sides of the equation by $(x+3)(x+4)$.
$(x+3)(x+4)\displaystyle\frac{x}{(x+3)(x+4)} = (x+3)(x+4)\displaystyle\frac{A}{x+3} + (x+3)(x+4)\displaystyle\frac{B}{x+4}$
which cancels to give
$$x = A(x+4) + B(x+3)$$
**Step 3. We plug in values to solve. **

Here we did two plug-ins:
* we plugged in $x = -4$ because it made the $(x+4)$ term become 0, giving an equation we could solve for **B**.
* we plugged in $x = 3$ because it made the $(x+3)$ term become 0, giving an equation we could solve for **A**.
**Step 4. Plug back in for the coefficient values!**
Since $A = -3$ and $B = 4$, we now know that
$$ \displaystyle\frac{x}{(x+3)(x+4)} = \displaystyle\frac{-3}{x+3} + \displaystyle\frac{4}{x+4}$$.
so
$$\displaystyle\int \displaystyle\frac{x}{(x+3)(x+4)} = \displaystyle\int \displaystyle\frac{-3}{x+3} + \displaystyle\frac{4}{x+4} dx$$
**Step 5. Actually Doing the Integral.** $$\displaystyle\int \displaystyle\frac{x}{(x+3)(x+4)} \;dx = \displaystyle\int \displaystyle\frac{-3}{x+3} + \displaystyle\frac{4}{x+4} \; dx $$ $$ = -3 \displaystyle\int \displaystyle\frac{1}{x+3} \; dx + 4 \displaystyle\int \displaystyle\frac{1}{x+4} \; dx $$
$$ = -3 \ln(|x+3|) + 4 \ln(|x+4|) + C$$
:slightly_smiling_face: Notice that we once we figured out how to rewrite the $$\displaystyle\frac{x}{(x+3)(x+4)}$$ as $\displaystyle\frac{-3}{x+3} + \displaystyle\frac{4}{x+4}$, the integral itself was straightforward.
---
**Video Example**
For a similar example, watch the video below:
<iframe width="560" height="315" src="https://www.youtube.com/embed/WoVdOcuSI0I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
---
**Example 2:**
Find $$\displaystyle\int \displaystyle\frac{2x + 3}{x^2 - x + 6} dx$$


---
**Example 3:** Find
$$\displaystyle\int \displaystyle\frac{1}{(x-1)(x+2)(x+3)} \; dx$$

This problem follows the same pattern as the first two examples, but there are now **three** distinct linear factors in the denominator to deal with.
This means we will need to do **three** plug-ins to deal with **three** linear equations.



However, just like the previous problems, once we get the rational expression written as a sum of simpler expressions, the integral is straightforward.