# Calculus

## Foreword

Started 14/06/2024

We have 2 goals in calculus:

- Find the tangent to the curve at a point
- Find the area under the curve between two points

Why do we give a shit? In AI we use

- The tangent to find the local/global max/min. We create a 2nd point on the curve which creates a secant. We move this second point towards the 1st point until we get a tangent, essentially $\dfrac{\Delta y}{\Delta x} = 0$ bc
`0`

means horizontally flat. - The area is used to assess whether this was an improvement or not. If you found a new tangent that is 0 / horizontally flat the area is what will indicate whether you’ve improved — the smaller the area for a minima the better performance you have.

## Limits

The whole point of limits is to get infinitely close to a point without being the point, e.g. $\lim_{0 \to 1}$. Then when you’re infinitely close to `1`

you have your secent will become the tangent.

We can think of the limit

$\lim_{0 \to 1} = \text{slope}_{secant \to 1}$And when the secant is making the jump from `0.99..`

it becomes a tangent, not longer being a limit

The function must approach from the left and right for the limit to exist.

## Differentials

`d`

means a lil bit of, e.g, $dx$ means a lil bit of `x`

. If `x = 10`

then $dx = 0.01$, we call this a **differential**. And this “small bit” is infinitely small so when you multiple it by itself $dx \cdot dx = (dx)^2$ it is virtually `0`

.

We can think of `dx`

as the change in `x`

when we’re observing the rate of change, e.g. $x + dx$ or $x + \Delta x$ where $\Delta$ means the change.

Sometimes $\phi$ (“phi”) is used instead of `f`

in `f(x)`

— $y = \phi(x)$

The ratio $\dfrac{dy}{dx}$ is the “differential coefficient of `y`

with respect to `x`

” which tells us how much of `y`

is changing relative to `x`

. “Differentiating” is the process of finding $\dfrac{dy}{dx}$.

We can think of $\dfrac{dy}{dx}$ as $\dfrac{\text{small bit of y}}{\text{small bit of y}}$, not $\dfrac{d \cdot y}{d \cdot x}$

If we see something like

$f''(x)$then the accents `'`

mean the function has differentiated with respect to `x`

once. Two accents `''`

means it’s been differentiated twice.

The aim of differentiation is to find the ratio of growth, of for example `y`

relative to `x`

.

## Integrals

Integrals are opposite of differentials by summing all of the little pieces together.

$\int$So we can find all the little pieces of `x`

w/ the notation

## Composite Functions

Combining two or more functions is called the “composition of functions”. Combining funcitons allows us to expand the range of causality.

E.g.,

$x \to f \to f(x) \to g \to g(f(x))$## Relative Error

The relative error gives the ratio of the difference between the values of `f(x)`

and `g(x)`

to the variation of `x`

when `x`

is changed.

We use this in AI to change model’s inputs to get closer to perfecting the action. If we’re playing basketball and miss a shot this calculates how far did we miss in all directions and how much to adjust by in the dimensions that matter.

$\text{Relative error } = \dfrac{\text{Difference between } f(x) \text{ and } g(x)}{\text{Change of }x}$Where,

`f(x)`

is our original fn — lets say in the basketball hoop`g(x)`

is our approximating fn — our shot to throw in the hoop

## Limits

We use $\epsilon$ to represent small quantities and to obtain a derivative.

Limits, represented as $\lim_{x \to 0} f(x)$, are used to represent the value a function as the input approaches a value. So for the epression `x`

is the closest it can be to `0`

without being `0`

.

We can calculate the derivative of linear function with the approximate function of $f(x)$. `k`

is called teh differential coefficient of `f(x)`

at `x = a`

.

We can find the **derivative** via the **difference quotient** w/ `f'(x)`

where we call it “f-prime”.

The derivative of `f(x)`

is `f′(x) = 0`

. This makes sense, since our function is constant—the rate of change is `0`