# Clearing up directional semi-derivatives for one dimension

This post clears up a confusion I ran into recently with directional semi-derivatives in one dimension.

Directional semi-derivatives

Consider a function $f: \mathbb{R}^d \mapsto \mathbb{R}$, where $d \geq 1$, and let $\mathbf{u} \in \mathbb{R}^d$ be a direction in $\mathbb{R}^d$ (i.e. a vector with length 1). For any point $\mathbf{x} \in \mathbb{R}^d$, the directional semi-derivative of $f$ at $\mathbf{x}$ in the direction $\mathbf{u}$ is given by \begin{aligned} \nabla_{\mathbf{u}} f(\mathbf{x}) = \lim_{h \rightarrow 0^+} \dfrac{f(\mathbf{x} + h \mathbf{u}) - f(\mathbf{x})}{h} \end{aligned}

if the limit exists. By $h \rightarrow 0^+$, we mean that $h$ approaches zero from the positive direction. Intuitively, the directional semi-derivative says that if I were to move a small positive distance $h$ from $\mathbf{x}$ in the direction $\mathbf{u}$, $f$ would increase by about $h \nabla_{\mathbf{u}}f(\mathbf{x})$.

In one dimension ( $d = 1$), there are only two directions: $\mathbf{u} = +1$ and $\mathbf{u} = -1$. The formula above simplifies to \begin{aligned} \nabla_{+1} f(x) = \lim_{h \rightarrow 0^+} \dfrac{f(x + h) - f(x)}{h}, \\ \nabla_{-1} f(x) = \lim_{h \rightarrow 0^+} \dfrac{f(x - h) - f(x)}{h}. \end{aligned}

One-sided derivatives

Some introductory courses on single-variable calculus introduce the concept of a one-sided derivative, also called left and right derivatives. For a function $f: \mathbb{R} \mapsto \mathbb{R}$, the right and left derivatives of $f$ at $x$ are defined respectively as \begin{aligned} \partial_+ f(x) &= \lim_{x' \rightarrow x^+} \dfrac{f(x') - f(x)}{x' - x}, \\ \partial_- f(x) &= \lim_{x' \rightarrow x^-} \dfrac{f(x') - f(x)}{x' - x}. \end{aligned}

Writing $x' = x+h$ in the first equation and $x' = x - h$ in the second equation, we can express the one-sided derivatives equivalently as \begin{aligned} \partial_+ f(x) &= \lim_{h \rightarrow 0^+} \dfrac{f(x+h) - f(x)}{h}, \\ \partial_- f(x) &= \lim_{h \rightarrow 0^+} \dfrac{f(x - h) - f(x)}{-h}. \end{aligned}

Notice that the directional semi-derivative matches the one-sided derivative for the positive direction but not for the negative direction! We have $\nabla_{+1} f(x) = \partial_+ f(x)$ but $\nabla_{-1} f(x) = -\partial_- f(x)$. Thus, one needs to be clear when defining these quantities in one dimension to avoid confusion.

References:

1. Wikipedia. Directional derivative.
2. Wikipedia. Semi-differentiability.