# Rules of Integration

The easiest expressions to integrate are polynomials. I'll reference constants included in the integration with $$k$$ and constants of integration as $$c$$.

As a quick refresher, whenever we evaluate an indefinite integral, meaning the general form and without limits of integration, we always include a constant in the final answer since the derivative of any constant is $$0$$.

### Integrating a Constant Function

$\int k\ dx = k\int 1\ dx = kx + c\,.$

.

Notice that this is a special case of the following power rule when $$n = 0$$.

### The Power Rule

When integrating any $$x^n$$ where $$n \neq -1$$,

$\int kx^n\ dx = \frac{k}{n+1} x^{n+1} + c \,.$

### The $$n = -1$$ Case

Integrating the reciprocal of $$x$$ yields the logarithmic function,

$\int \frac{1}{kx}\ dx = \frac{1}{k}\int (x)^{-1}\ dx = \frac{1}{k}\log |x| + c\,.$

### Exponentials

The exponential function is simultaneously the most boring and most interesting function of all.

$\int e^{\pm kx}\ dx = \pm \frac{1}{k} e^{\pm kx} + c\,.$

The Taylor Series expansion of the exponential function, which is defined for all reals, $$\mathbb{R}$$, is,

$e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots\,,$

or more compactly written as,

$e^x = \sum_{n=0}^\infty x^n\,.$

### Trigonometric Functions

Table of common trig integrations coming soon...

## Variable Substitutions

Given a function such as, $$f(x) = \sqrt{k_1 + k_2 x }$$, we can perform a simple substitution such as, $$u = k_1 + k_2 x$$. Since we'll also need to transform the $$dx$$ variable as well, we differentiate $$u$$ to access $$dx$$,

\begin{aligned} u &= k_1 + k_2 x \\ du &= k_2\ dx \implies dx = \frac{1}{k_2}\ du \end{aligned}

Therefore, plugging $$(7)$$ into the integration,

$\int \sqrt{k_1 + k_2 x }\ dx \rightarrow \frac{1}{k_2}\int \sqrt{u}\ du\,,$

and since roots are just fractional exponents, we apply the power rule and then substitute the original function back in for $$u$$,

\begin{aligned}\frac{1}{k_2}\int u^{1/2}\ du &= \frac{1}{k_2}\frac{1}{\frac{3}{2}} u^{3/2} + c \\ &= \frac{2}{3k_2} u^{3/2} + c \\ &= \frac{2}{3k_2}\sqrt{(k_1 + k_2 x)^3} + c \end{aligned}

Don't forget to account for all of the variables! In this case, when we differentiated, all of the $$x$$ variables went away and we are perfectly fine to move constants around in the integrand. However, suppose that inside of the square root was an $$x^n$$ term where $$n \geq 2$$, then when differentiating we would still have an $$x$$ term left over. Since $$x$$ is the variable we are integrating with respect to, that wouldn't work. Suppose that the original function was $$f(x) = x\sqrt{k_1 + k_2 x^2}$$. In this case, we could set $$u = k_1 + k_2 x^2$$, differentiate to get $$du = 2 k_2 x\ dx$$ and this would work fine because we can equate the left over $$x$$ with the $$x$$ in front of the square root and all is right in the world.

## Integration By Parts (the Product Rule for Integration)

$\int u\ dv = u\cdot v - \int v\ du$

Suppose $$u$$ and $$v$$ are functions are $$x$$.

$\frac{d}{dx}(u\cdot v) = u\frac{d}{dx}v + v\frac{d}{dx}u$ \begin{aligned} \int \frac{d}{dx}(u\cdot v)\ dx &= \int u\frac{d}{dx}v\ dx + \int v\frac{d}{dx}u\ dx \\ \int u\frac{d}{dx}v\ dx + \int v\frac{d}{dx}u\ dx &= \int \frac{d}{dx}(u\cdot v)\ dx \\ \int u\ dv &= u\cdot v - \int v\ du \\ \end{aligned}

As an example, suppose we are evaluating, $$\int e^x \cos(x)\ dx$$.

Follow the mnemonic, LIATE (Logarithms, Inverse Trig, Algebraic, Trig, and Exponential) for selecting $$u$$ and $$dv$$.

\begin{aligned} u &= \cos(x) \\ du &= -\sin(x)\ dx \\ dv &= e^x\ dx\\ v &= e^x \\ \end{aligned} $\int e^x \cos(x)\ dx = e^x \cos(x) + \int e^x \sin(x)\ dx$

We need to play the same game with the $$v\ du$$ term.

\begin{aligned} u &= \sin(x) \\ du &= \cos(x)\ dx \\ dv &= e^x\ dx\\ v &= e^x \\ \end{aligned} $\int e^x \sin(x)\ dx = e^x \sin(x) - \int e^x \cos(x)\ dx$ \begin{aligned} \int e^x \cos(x)\ dx &= e^x \cos(x) + \Big[ e^x \sin(x) - \int e^x \cos(x)\ dx \Big]\\ &= e^x \cos(x) + e^x \sin(x) - \int e^x \cos(x)\ dx \end{aligned}

Let $$I = \int e^x \cos(x)\ dx$$, then

\begin{aligned} I &= e^x \cos(x) + e^x \sin(x) - I\\ 2I &= e^x \cos(x) + e^x \sin(x) \\ \\ \int e^x \cos(x)\ dx &= \frac{e^x}{2}\Big(\cos(x) + \sin(x)\Big) + c \end{aligned}