Chapter 2
Derivatives
Definition
Derivative
If the limit
exists,
is differentiable at and is its derivative there.
Geometrically,
Common derivatives
A numerical check
For small
const derivative = (f: (x: number) => number, x: number, h = 1e-5): number =>
(f(x + h) - f(x - h)) / (2 * h)
console.log(derivative(Math.sin, 0)) // ≈ 1 = cos(0)Why a central difference
The central difference has error
; a one-sided difference has error . For the same , the former is far more accurate.
The chain rule
If
Comments