# Antiderivatives
An antiderivative is useful when you know the rate of change, and you want to find a point from that rate of change

> A function $F$ is said to be an *antiderivative* of $f$ if $F'(x) = f(x)$ 
## Notation
The collection of all antiderivatives of a function $f$ is referred to as the *indefinite integral of $f$ with respect to $x$*, and is denoted by:
$$ \int f(x) dx $$
## Examples
> Find the antiderivative of the function $y = x^2$

1. We know that to find the derivative of the above function, you'd multiply by the exponent ($2$), and subtract 1 from the exponent.
2. To perform this operation in reverse:
	1. Add 1 to the exponent
	2. Multiply by $\dfrac{1}{n + 1}$
3. This gives us an antiderivative of $\dfrac{1}{3}x^3$ 
4. To check our work, work backwards.
5. The derivative of $\dfrac{1}{3}x^3$ is $\dfrac{1}{3} (3x^2)$
6. $= \dfrac{3}{3} x^2$


## Formulas

| Differentiation Formula                               | Integration Formula                                      |
| ----------------------------------------------------- | -------------------------------------------------------- |
| $\dfrac{d}{dx} x^n = nx^{x-1}$                        | $\int x^n dx = \dfrac{1}{n+1}x^{n+1}+ C$ for $n \ne -1$  |
| $\dfrac{d}{dx} kx = k$                                | $\int k \space dx = kx + C$                              |
| $\dfrac{d}{dx} \ln \|x\| = \dfrac{1}{x}$              | <br>$\int \dfrac{1}{x}dx = \ln \|x\| + C$                |
| $\dfrac{d}{dx} e^x = e^x$                             | <br>$\int e^x dx = e^x + C$                              |
| $\dfrac{d}{dx} a^x = (\ln{a}) a^x$                    | $\int a^xdx = \ln \|x\| + C$                             |
| $\dfrac{d}{dx} \sin x = \cos x$                       | $\int \cos(x) dx  = \sin (x) + C$                        |
| $\dfrac{d}{dx} \cos x = -\sin x$                      | $\int \sin(x)dx = \sin x + C$                            |
| $\dfrac{d}{dx} \tan{x} = \sec^2 x$                    | $\int \sec^2(x)dx = \tan(x) + C$                         |
| $\dfrac{d}{dx} \sec x = \sec x \tan x$                | $\int sec^2(x) dx = \sec(x) + C$                         |
| $\dfrac{d}{dx} \sin^{-1} x = \dfrac{1}{\sqrt{1-x^2}}$ | $\int \sec(x) \tan(x) dx = \sec x + C$                   |
| $\dfrac{d}{dx} \tan^{-1} x = \dfrac{1}{1+x^2}$        | $\int \dfrac{1}{\sqrt{1+x^2}}dx = \tan^{-1}x + C$        |
| $\dfrac{d}{dx} k f(x) = k f'(x)$                      | $\int k*f(x)dx = k\int f(x)dx$                           |
| $\dfrac{d}{dx} f(x) \pm g(x) = f'(x) \pm g'(x)$       | $\int (f(x) \pm g(x))dx = \int f(x) dx \pm \int g(x) dx$ |
# Area Under a Curve
The area under the curve $y = f(x)$ can be approximated by the equation $\sum_{i = 1}^n f(\hat{x_i})\Delta x$ where $\hat{x_i}$ is any point on the interval $[x_{i - 1}, x_i]$, and the curve is divided into $n$ equal parts of width $\Delta x$

Any sum of this form is referred to as a Reimann Sum.

To summarize:
- The area under a curve is equal to the sum of the area of $n$ rectangular subdivisions where each rectangle has a width of $\Delta x$ and a height of $f(x)$.
# Definite Integrals
Let $f$ be a continuous function on the interval $[a, b]$. Divide $[a, b]$ into $n$ equal parts of width $\Delta x = \dfrac{b - a}{n}$ . Let $x_0, x_1, x_2, \cdots, x_3$ be the endpoints of the subdivision.

The definite integral of $f(x)$ with respect to $x$ from $x = a$ to $x = b$ can be denoted:
$$ \int_{a}^b f(x) dx $$

And __can__ be defined as:
$$ \int_a^b f(x) dx = \lim_{n \to \infty} \sum_{i = 1}^n f(x_i)\Delta x$$

$f(x_i)$ is the *height* of each sub-interval, and $\Delta x$ is the change in the *x* interval, so $f(x_i) \Delta x$ is solving for the area of each sub-interval.

- If your function is always positive, then the value of a definite integral is the area under the curve.
- If the function is always negative, then the value of a definite integral is the area above the curve to zero.
- If the function has both positive and negative values, the output is equal to the area above the curve minus the area below the curve.

## Examples
> Find the exact value of the integral $\int_0^1 5x \space dx$ 

Relevant formulas:
$$ \sum_{i = 1}^n = \dfrac{(n)(n + 1)}{2} $$
$$ \Delta x = \dfrac{1 - 0}{n} = \dfrac{1}{n}$$$$ x_i = 0 + \Delta xi + \dfrac{1}{n} \cdot i$$
1. $\int_0^1 5x \space dx = \lim_{n \to \infty} \sum_{i=1}^n 5(x_i) \cdot \Delta x$
2. $= \lim_{n \to \infty} \sum_{i=1}^n 5(\frac{1}{n} \cdot i) \cdot \frac{1}{n}$ 
3. $= \lim_{n \to \infty} \sum_{i = 1}^n \dfrac{5}{n^2}\cdot i$ 
4. $= \lim_{n \to \infty} \dfrac{5}{n^2} \sum_{i = 1}^n i$
5. $= \lim_{x \to \infty} \dfrac{5}{n^2} \cdot \dfrac{n(n + 1)}{2}$ 
6. $= \lim_{n \to \infty} \dfrac{5n^2 + 5n}{2n^2}$
7. $= \dfrac{5}{2}$ 

# Properties of Integrals
1. $\int_a^a f(x)dx = 0$ - An integral with a domain of zero will always evaluate to zero.
2. $\int_b^a f(x)dx = -\int_a^b f(x) dx$  - The integral from $a \to b$ is equal to the integral from $-(b\to a)$ 
3. $\int_a^b cf(x) dx = c \int_a^b f(x) dx$ - A constant from inside of an integral can be moved outside of an integral
4. $\int_a^b f(x) \pm g(x) dx = \int_a^b f(x) dx \pm \int_a^b g(x)dx$  - Integrals can be distributed
5. $\int_a^c f(x)dx = \int_a^b f(x)dx + \int_b^c f(x)dx$  - An integral can be split into two smaller integrals covering the same domain, added together.

# Averages
To find the average value of $f(x)$ on the interval $[a, b]$ is given by the formula:

Average = $\dfrac{1}{b-a} \int_a^b f(x)dx$ 

# The Fundamental Theorem of Calculus
1. Let $f$ be a continuous function on the closed interval $[a, b]$ and let $F$ be any antiderivative of $f$, then:
$$\int_a^b f(x) dx = F(b) - F(a)$$
2. Let $f$ be a continuous function on $[a, b]$ and let $x$ be a point in $[a, b]$.
$$ F(x) = \int_a^x f(t)dt \Rightarrow F'(x) = f(x) $$
This basically says that cancelling out the derivative from $a$ to $x$ can be done by taking the derivative of that equation. with respect to $x$.
$$ \dfrac{d}{dx} \int_a^{g(x)} f(t) dt = f(g(x)) * g'(x)* $$
## Examples
> Finding the derivative of an integral
$$ \dfrac{d}{dx} \int_2^{7x} \cos(t^2) dt = cos((7x)^2) * 7 = 7\cos(49x^2)$$
> Finding the derivative of an integral
$$ \dfrac{d}{dx}\int_0^{\ln{x}}\tan(t) = \tan(\ln(x))*\dfrac{1}{x} $$
> $x$ and $t$ notation *(note: the bar notation is referred to as "evaluated at")*
$$ F(x) = \int_4^x 2t \space dt = t^2 \Big|_4^x  = x^2 - 16$$
> $x$ in top and bottom
$$ \dfrac{d}{dx} \int_{2x}^{3x} \sin(t) dt = \dfrac{d}{dx} -\cos(t)\Big|_{2x}^{3x} = \dfrac{d}{dx} (-\cos(3x) + cos(2x) = 3\sin(3x) - 2\sin(2x) $$

# The Mean Value Theorem for Integrals
If $f(x)$ is continuous over an interval $[a, b]$ then there is at least one point $c$ in the interval $[a, b]$ such that:
$$f(c) = \dfrac{1}{b-a}\int_a^bf(x)dx $$
This formula can also be stated as $\int_a^b f(x)dx = f(c)(b-a)$
This theorem tells us that a continuous function on the closed interval will obtain its average for at least one point in the interval.

# U-Substitution
When you see $dx$ or $du$ in a function, it can be thought of as roughly analogous to $\Delta x$, where the change in $x$ is infinitesimally small.

Thinking back to derivatives, when solving for $\dfrac{dy}{dx}$, you're solving for the rate of change of $y$ (across an infinitely small distance) over the rate of change of $x$ (across an infinitely small instance). Given that the *slope* of a line is described as $\dfrac{\text{rise}}{\text{run}}$, we know that $\dfrac{dy}{dx}$ describes the slope of a line at a particular point.
## Formulas
- $\int k {du} = ku + C$
- $\int u^n du = \frac{1}{n+1}u^{n+1} + C$
- $\int \frac{1}{u} du = \ln(|u|) + C$ 
- $\int e^u du = e^u + C$
- $\int \sin(u) du = -\cos(u) + C$
- $\int \cos(u) du = \sin(u) + C$
- $\int \dfrac{1}{\sqrt{a^2 - u^2}} du = \arcsin(\frac{u}{a}) +C$ 
- $\int \dfrac{1}{a^2+u^2}du = \dfrac{1}{a} \arctan(\frac{u}{a}) + C$ 
- $\int \dfrac{1}{u\sqrt{u^2 - a^2}} du = \dfrac{1}{a}arcsec(\dfrac{|u|}{a}) + C$  

# Length of a Curve
## Review of the Mean Value Theorem
If $f$ is a continuous function on the interval $[a, b]$ and differentiable on $(a, b)$, then there exists a number $c$ in the interval $(a, b)$ such that:

$$ f'(c) = \dfrac{f(b) - f(a)}{b - a} $$

This also implies that for some $c$ in the interval $(a, b)$:
$$ f(b) - f(a) = f'(c)(b-a) $$

## Intuitive Approach
Given that we divide a curve into $n$ sub-intervals, and we can find the location of the right endpoint of each interval.

With a series of points on a curve we can find the distance between each point.

As we increase $n$, the precision of which the curve is estimated increases.

This means that:
$$ \text{length of a curve} = \lim_{n \to \infty} \sum_{i=1}^{n}(\text{length of line segment)}$$
Using the distance formula, we know that the length of the line segment can be found with:
$$ \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} $$
1. So the entire equation is:
$$ \text{length of a curve} = \lim_{n \to \infty} \sum_{i=1}^{n}(\sqrt{(x_i - x_{i-1})^2 + (y_i - y_{i-1})^2}) $$
	This can also be described as:
$$ \text{length of a curve} = \lim_{n \to \infty} \sum_{i=1}^{n}(\sqrt{(\Delta x)^2 +(\Delta y)^2}) $$
2. Using the mean value theorem:
$$ \lim_{n \to \infty} \sum_{i = 1}^n\sqrt{\Delta x^2 + (f(x_i) - f(x_{i-1}))i^2} $$l
$$ \lim_{n \to \infty} \sum_{i=1}^n \sqrt{\Delta x ^2 + (f'(x_{\hat{i}}))(x_i - x_{i-1})^2}$$
3. Factoring out $\Delta x$
$$ \lim_{n \to \infty} \sum_{i=1}^n \sqrt{\Delta x^2(1 + f'(x_{\hat{i}}))}$$
4. Moving $\Delta x$ out of the root

$$ \lim_{n \to \infty} \sum_{i=1}^n \sqrt{(1 + f'(x_{\hat{i}}))} \Delta x$$
5. As an integral:
$$ L =\int_a^b \sqrt{1 + f'(x)^2} dx$$
## Examples
> Find the length of the curve $y = -\frac{5}{12}x + \frac{7}{12}$ from the point $(-1, 1)$

1. $L = \int_{-1}^8 \sqrt{1 + (-\frac{5}{12})^2} dx$ 
2. $= \int_{-1}^8 \sqrt{1 + \frac{25}{144}} dx$ 
3. = $\int_{-1}^8 \sqrt{\frac{169}{144}}dx$
4. $= \int_{-1}^8 \frac{13}{12} dx$
5. $\frac{13}{12} x \Big| _{-1}^8$

> Find the distance from the point ${\frac{1}{2}, \frac{49}{48}}$ to the point $(5, \frac{314}{15})$ along the curve $y = \dfrac{x^4 - 3}{6x}$.
> *note*: The complete evaluation of this problem is more work than typically required, and is only done for demonstration purposes.
1. $y' = \dfrac{4x^3(6x) - (x^4 + 3)6}{36x^2}$: Find the derivative of the curve using the quotient rule
2. $= \dfrac{18x^4 - 18}{36x^2}$: Simplify
3. $= \dfrac{18(x^4 - 1)}{18(2x^2)}$: Factor out $18$
4. $= \dfrac{x^4 - 1}{2x^2}$: Factor out $18$ again
5. $L = \int_{1/2}^5 \sqrt{1 + (\dfrac{4x-1}{2x^2})^2}dx$ : Use the length formula
6. $= \int_{1/2}^5 \sqrt{1 + \dfrac{x^8 - 2x^4 + 1}{x^4}} dx$: Apply the $^2$ 
7. $= \int_{1/2}^5 \sqrt{\dfrac{4x^4 + x^8 -2x^4 + 1}{4x^4}}dx$: Set $1 = \dfrac{4x^4}{4x^4}$ and add
8. $= \int_{1/2}^5 \sqrt{\dfrac{x^8 + 2x^4 + 1}{4x^4}}dx$: Factor the numerator
9. $= \int_{1/2}^5 \sqrt{\dfrac{(4x+1)^2}{4x^4}}dx$ : Get rid of the square root
10. = $\int_{1/2}^5 \dfrac{x^4 + 1}{2x^2}dx$: Move the constant $\frac{1}{2}$ outside of the integral
11. $= \frac{1}{2}\int_{1/2}^5 \dfrac{x^4 + 1}{x^2}$: Rewrite to remove the fraction
12. $= \frac{1}{2} \int_{1/2}^5 (x^4 + 1)(x^{-2})dx$: distribute
13. $= \frac 1 2 \int_{1/2}^5 (x^2 - x^{-2})dx$: Find the indefinite integral
14. $= \dfrac{1}{2} (\frac{1}{3}x^3 - x^-1)\Big|_{1/2}^5$ : Plug and chug
15. $= (\frac{125}{6} - \frac{1}{10}) - (\frac{1}{48} - 1)$ 
16. $=(\frac{5000}{240} - \frac{24}{240}) - (\frac{5}{240} - \frac{240}{240})$ 

> Find the length of the curve $y = \sqrt{1 - x^2}$
1. $y$ has a domain of $[-1, 1]$
2. $y' = \dfrac{1}{2}(1-x^2)^{-1/2}(-2x)$
3. $= -\dfrac{x}{\sqrt{1 - x^2}}$
4. $L = \int_{-1}^1 \sqrt{1 + (-\dfrac{x}{\sqrt{1-x^2}})^2}dx$ 
5. $L = \int_{-1}^1 \sqrt{1 + \dfrac{x^2}{1-x^2}}dx$ 
6. $L = \int_{-1}^1 \sqrt{\dfrac{1}{1-x^2}}dx$ 
7. $L = \int_{-1}^1 \dfrac{1}{\sqrt{1-x^2}}dx$ 
8. $L = \arcsin(x) \Big|_{-1}^1$ 

> Set up an integral to find the length of the curve $y = \sin(x)$ from the point $(0, 0)$ to the point $(2\pi, 0)$.

1. $L = \int_0^{2\pi} \sqrt{1 + \cos^2{x}}dx$ :  The derivative of $\sin$ is $\cos$
2. Plug into calculator

# Area Between Curves
If the area under the curve is found by approximating the space between the curve and the $x$ intercept, then the area *between* two curves can be found by approximating the space between the top curve and the bottom curve.

Visualized as a set of rectangles, each rectangle would have a corner on the top curve, and a corner on the bottom curve, with a width of $\Delta x$.

The height of the rectangle, or the distance between the curves at a given point can be found with the formula $f(x) - g(x)$ where $f(x) \ge g(x)$ 

The Riemann Sum definition of the area between two curves is as follows:

$$ \lim_{n \to \infty} \sum_{i = 1}^n (f(x_i)-g(x_i)\cdot \Delta x)$$
- $i$ is the sub-interval
- $x_i$ is the $x$ coordinate at a given sub-interval
- $\Delta x$ is the width of each sub-interval.

This sum can also be described as:
$$ = \int_a^b(f(x)-g(x))dx $$

Where the two lines intersect each other, you'll need to split the solution into a sum of integrals to ensure that $f(x) \ge g(x)$, by swapping the two.

# Rotating a Solid Formed from a Rotation of a Plane Region
Similar to finding the area between two curves, the volume can be found by approximating with rectangles.

The area of each slice can be found by taking the area of the inner circle ($\pi r^2$) and subtracting it from the bigger circle ($\pi R ^2$). The area of a washer (or cylinder) can be found with $\text{base} * \text{height}$, and the height of each subsection is $\Delta x$. 

The Riemann Sum definition is defined as follows:
$$ \lim_{x \to \infty} \sum_{i = 1}^n ((\pi\cdot(f(x_i))^2-\pi\cdot(g(x_i))^2)\Delta x$$
- $\Delta x$: The width of each section
- $\pi * (f(x_i))^2$: The area of larger circle formed by $f(x_i)$
- $\pi * (f(x_i))^2$: The area of smaller circle formed by $f(x_i)$