[proofplan]
The proof is a direct locality argument from the defining difference quotients. First we shrink the given neighbourhood so that points on the nearby $u$-line through $a$ remain inside the region where $f$ and $g$ agree. At each such point, the first directional derivatives in direction $v$ are equal because their defining one-variable difference quotients use only values of $f$ and $g$ inside the same neighbourhood. Finally the outer [directional derivative](/page/Directional%20Derivative) in direction $u$ is computed from two functions that agree near $a$ along the $u$-line, so the iterated derivatives are equal.
[/proofplan]
custom_env
admin
[step:Choose a neighbourhood on which the nearby $u$-line stays inside the equality region]Since $W$ is an open neighbourhood of $a$ in $\mathbb{R}^m$, there exists $r>0$ such that the open Euclidean ball $B(a,r):=\{y\in\mathbb{R}^m:|y-a|<r\}$ is contained in $W$. Define the positive number $\eta$ as follows: if $u\ne 0$, set $\eta:=r/(2|u|)$, and if $u=0$, set $\eta:=1$.
If $s \in \mathbb{R}$ satisfies $|s|<\eta$, then $a+su \in B(a,r)\subset W$. Indeed, when $u\ne 0$,
\begin{align*}
|a+su-a|=|s|\,|u|<\frac{r}{2}<r,
\end{align*}
and when $u=0$ we have $a+su=a\in W$.[/step]
custom_env
admin
[guided]We need a neighbourhood small enough that the outer difference quotients for the direction $u$ only sample points where the two functions are already known to agree locally. Since $W$ is open and contains $a$, there is a radius $r>0$ for which the open Euclidean ball $B(a,r):=\{y\in\mathbb{R}^m:|y-a|<r\}$ is contained in $W$.
Define $\eta>0$ as follows: if $u\ne 0$, set $\eta:=r/(2|u|)$, and if $u=0$, set $\eta:=1$. This definition separates the case $u=0$ only to avoid dividing by $|u|$. If $u\ne 0$ and $|s|<\eta$, then
\begin{align*}
|a+su-a|=|s|\,|u|<\frac{r}{2}<r.
\end{align*}
Thus $a+su\in B(a,r)\subset W$. If $u=0$, then $a+su=a$ for every $s\in\mathbb{R}$, so $a+su\in W$ as well. Therefore, for all sufficiently small real $s$, the point at which the inner $v$-directional derivative is evaluated lies inside the equality neighbourhood $W$.[/guided]
custom_env
admin
[step:Show the first directional derivatives in direction $v$ agree at nearby points]
Let $x\in W$ be a point at which both $D_v f(x)$ and $D_v g(x)$ exist. By the definition of directional derivative, these are the limits of the difference quotients along the map $t\mapsto x+tv$. Since $W$ is open, there exists $\delta_x>0$ such that $x+tv\in W$ whenever $t\in\mathbb{R}$ and $|t|<\delta_x$. For every nonzero $t$ with $|t|<\delta_x$, the hypothesis $f=g$ on $W$ gives
\begin{align*}
\frac{f(x+tv)-f(x)}{t}=\frac{g(x+tv)-g(x)}{t}.
\end{align*}
Taking the limit as $t\to 0$ in $\mathbb{R}$ and using the assumed existence of both limits yields
\begin{align*}
D_v f(x)=D_v g(x).
\end{align*}
[/step]
custom_env
admin
[step:Compare the outer directional difference quotients]
By the definition of the [iterated directional derivative](/page/Iterated%20Directional%20Derivative) stated in the theorem, $D_uD_v f(a)$ is the limit as $s\to 0$ of the outer difference quotient built from the partially defined map $x\mapsto D_v f(x)$, and similarly for $g$. Thus, for all sufficiently small nonzero $s\in\mathbb{R}$ appearing in these quotients, the quantities $D_v f(a+su)$, $D_v g(a+su)$, $D_v f(a)$, and $D_v g(a)$ are defined. For every such sufficiently small nonzero $s$, the point $a+su$ lies in $W$ by the first step. Applying the previous step with $x=a+su$ gives
\begin{align*}
D_v f(a+su)=D_v g(a+su).
\end{align*}
Applying the previous step with $x=a$ also gives
\begin{align*}
D_v f(a)=D_v g(a).
\end{align*}
Therefore the two outer difference quotients are equal:
\begin{align*}
\frac{D_v f(a+su)-D_v f(a)}{s}=\frac{D_v g(a+su)-D_v g(a)}{s}.
\end{align*}
Since the limits of the left-hand and right-hand sides as $s\to 0$ exist by hypothesis, the limits are equal. Hence
\begin{align*}
D_uD_v f(a)=D_uD_v g(a).
\end{align*}
This is the desired locality statement for iterated directional derivatives.
[/step]