# Integration by Parts

We saw that substitution rule helps us solve chain rule related derivatives with relative ease. Integration by parts is a method used to solve product rule related derivatives.

**Integration
by Parts: **For functions in the form $f(x)g'(x)$,
the integral $\int f(x)g'(x) dx = f(x)g(x) - \int g(x)f'(x) dx$

Often, we choose to represent f(x) = u and g(x) = v to make the formula more compact and easy to remember: $\int u dv = uv - \int v du$

**Example:
**Find $\int xsin(x) dx$

For this example, we can select u = x and dv = sin(x), then du = 1 and v = -cos(x). Now we plug this into our formula to get

$\int xsin(x) dx = -xcos(x) - \int (-cos(x)) * 1 = -xcos(x) + sin(x)+C$

When we are selecting u and dv, we need to be careful with our selections. You might notice an alternative option would be to choose u = sin(x) and dv = x. This would give us du = cos(x) and v = $\frac{1}{2}x^2$. This would make our formula:

$\int xsin(x) dx = sin(x)*\frac{1}{2}x^2 - \int \frac{1}{2}x^2 * cos(x)$

This formula results in an integral that is just as hard as the original, meaning it doesn't benefit us at all. When we are picking the u value, there is a general rule that helps, known as LIATE. LIATE stands for Logarithm, Inverse trig, Algebraic, Trigonometric, Exponential. It is the order of preference for picking a u value. For example, x is algebraic and sin(x) is trigonometric, since algebraic comes first, we prefer it over sin(x).

**Example:
**Find $\int t^2 e^t dt$

Following the idea of LIATE, we have an algebraic term, and an exponential term. We prefer the algebraic term, meaning $u = t^2$, and $dv = e^t$. This gives us $u = 2t$ and $v = e^t$, meaning we get the integral:

$\int t^2 e^t dt = t^2 * e^t - \int e^t * 2t$

Notice that $e^t * 2t$ is still relatively hard to solve. In cases like this, we need to apply integration by parts again. We can pick u = 2t, $dv = e^t$. This gives us du = 2 and $v = e^t$, meaning:

$=t^2 * e^t - 2t * e^t - \int e^t * 2 = t^2e^t - 2te^t+2e^t + C$