This article provides counterexamples about differentiability of functions of several real variables. We focus on real functions of two real variables (defined on \(\mathbb R^2\)). \(\mathbb R^2\) and \(\mathbb R\) are equipped with their respective Euclidean norms denoted by \(\Vert \cdot \Vert\) and \(\vert \cdot \vert\), i.e. the absolute value for \(\mathbb R\).

We recall some definitions and theorems about differentiability of functions of several real variables.

**Definition 1** We say that a function \(f : \mathbb R^2 \to \mathbb R\) is **differentiable** at \(\mathbf{a} \in \mathbb R^2\) if it exists a (continuous) linear map \(\nabla f(\mathbf{a}) : \mathbb R^2 \to \mathbb R\) with \[\lim\limits_{\mathbf{h} \to 0} \frac{f(\mathbf{a}+\mathbf{h})-f(\mathbf{a})-\nabla f(\mathbf{a}).\mathbf{h}}{\Vert \mathbf{h} \Vert} = 0\]

**Definition 2** Let \(f : \mathbb R^n \to \mathbb R\) be a real-valued function. Then the **\(\mathbf{i^{th}}\) partial derivative** at point \(\mathbf{a}\) is the real number

\begin{align*}

\frac{\partial f}{\partial x_i}(\mathbf{a}) &= \lim\limits_{h \to 0} \frac{f(\mathbf{a}+h \mathbf{e_i})- f(\mathbf{a})}{h}\\

&= \lim\limits_{h \to 0} \frac{f(a_1,\dots,a_{i-1},a_i+h,a_{i+1},\dots,a_n) – f(a_1,\dots,a_{i-1},a_i,a_{i+1},\dots,a_n)}{h}

\end{align*} For two real variable functions, \(\frac{\partial f}{\partial x}(x,y)\) and \(\frac{\partial f}{\partial y}(x,y)\) will denote the partial derivatives.

**Definition 3** Let \(f : \mathbb R^n \to \mathbb R\) be a real-valued function. The directional derivative of \(f\) along vector \(\mathbf{v}\) at point \(\mathbf{a}\) is the real \[\nabla_{\mathbf{v}}f(\mathbf{a}) = \lim\limits_{h \to 0} \frac{f(\mathbf{a}+h \mathbf{v})- f(\mathbf{a})}{h}\]

Now some theorems about differentiability of functions of several variables.

**Theorem 1** Let \(f : \mathbb R^2 \to \mathbb R\) be a continuous real-valued function. Then \(f\) is continuously differentiable if and only if the partial derivative functions \(\frac{\partial f}{\partial x}(x,y)\) and \(\frac{\partial f}{\partial y}(x,y)\) exist and are continuous.

**Theorem 2 **Let \(f : \mathbb R^2 \to \mathbb R\) be differentiable at \(\mathbf{a} \in \mathbb R^2\). Then the directional derivative exists along any vector \(\mathbf{v}\), and one has \(\nabla_{\mathbf{v}}f(\mathbf{a}) = \nabla f(\mathbf{a}).\mathbf{v}\).

### A differentiable function with discontinuous partial derivatives

Consider the function defined on \(\mathbb R^2\) by

\[f(x,y)=\begin{cases}(x^2+y^2)\sin\left(\frac{1}{\sqrt{x^2+y^2}}\right) & \text{ if } (x,y) \ne (0,0)\\

0 & \text{ if }(x,y) = (0,0).\end{cases}\] \(f\) is obviously continuous on \(\mathbb R^2 \setminus \{(0,0)\}\). \(f\) is also continuous at \((0,0)\) as for \((x,y) \neq (0,0)\) \[\left\vert (x^2+y^2)\sin\left(\frac{1}{\sqrt{x^2+y^2}}\right) \right\vert \le x^2+y^2 = \Vert (x,y) \Vert^2 \mathrel{\mathop{\to}_{(x,y) \to (0,0)}} 0 \] \(f\) is also differentiable at all \((x,y) \neq (0,0)\). Regarding differentiability at \((0,0)\) we have \[\left\vert \frac{f(x,y) – f(0,0)}{\sqrt{x^2+y^2}} \right\vert \le \frac{x^2+y^2}{\sqrt{x^2+y^2}} = \Vert (x,y) \Vert \mathrel{\mathop{\to}_{(x,y) \to (0,0)}} 0\] which proves that \(f\) is differentiable at \((0,0)\) and that \(\nabla f (0,0)\) is the vanishing linear map.

The partial derivatives of \(f\) are zero at the origin. For example, the derivative with respect to \(x\) can be calculated by

\begin{align*}

\frac{\partial f}{\partial x}(0,0) &= \lim_{h \to 0}

\frac{f(h,0)-f(0,0)}{h}\\

&= \lim_{h \to 0}\frac{h^2 \sin (1/|h|)-0}{h} \\

&= \lim_{h \to 0}h \sin (1/|h|) =0.

\end{align*}

A similar calculation shows that \(\frac{\partial f}{\partial x}(0,0)=0\).

Away from the origin, one can use the standard differentiation formulas to calculate that

\begin{align*}

\frac{\partial f}{\partial x}(x,y) &= 2 x \sin

\left(\frac{1}{\sqrt{x^2+y^2}}\right)-\frac{x \cos

\left(\frac{1}{\sqrt{x^2+y^2}}\right)}{\sqrt{x^2+y^2}}\\

\frac{\partial f}{\partial y}(x,y) &= 2 y \sin

\left(\frac{1}{\sqrt{x^2+y^2}}\right)-\frac{y \cos

\left(\frac{1}{\sqrt{x^2+y^2}}\right)}{\sqrt{x^2+y^2}}.

\end{align*}

Both of these derivatives oscillate wildly near the origin. For example, the derivative with respect to \(x\) along the \(x\)-axis is \(\frac{\partial f}{\partial x}(x,0) = 2 x \sin

\left(1/|x|\right)-\text{sign}(x) \cos

\left(1/|x|\right),\)

for \(x \neq 0\), where \(\text{sign}(x)\) is \(\pm 1\) depending on the sign of \(x\). In this case, the sine term goes to zero near the origin but the cosine term oscillates rapidly between \(-1\) and \(+1\). Hence \(\frac{\partial f}{\partial x}\) is discontinuous at the origin. In the same way, one can show that \(\frac{\partial f}{\partial y}\) is discontinuous at the origin.

This counterexample proves that **theorem 1** cannot be applied to a differentiable function in order to assert the existence of the partial derivatives. Continuity of the derivative is absolutely required!

### A function having partial derivatives which is not differentiable

We now consider the converse case and look at \(g\) defined by

\[g(x,y)=\begin{cases}\frac{xy}{\sqrt{x^2+y^2}} & \text{ if } (x,y) \ne (0,0)\\

0 & \text{ if }(x,y) = (0,0).\end{cases}\] For all \((x,y) \in \mathbb R^2\) we have \(x^2 \le x^2+y^2\) hence \(\vert x \vert \le \sqrt{x^2+y^2}=\Vert (x,y) \Vert\). Similarly, \(\vert y \vert \le \Vert (x,y) \Vert\) and therefore \(\vert g(x,y) \vert \le \Vert (x,y) \Vert\). This last inequality being also valid at the origin. Consequently, \(g\) is a continuous function. The partial maps \(x \mapsto g(x,0)\) and \(y \mapsto g(0,y)\) are always vanishing. Hence \(g\) has partial derivatives equal to zero at the origin.

As a consequence, if \(g\) was differentiable at the origin, its derivative would be equal to zero and we would have \[\lim\limits_{(x,y) \to (0,0)} \frac{\vert g(x,y) \vert}{\Vert (x,y) \Vert} = 0\] That is not the case as for \(x \neq 0\) we have \(\displaystyle \frac{\vert g(x,y) \vert}{\Vert (x,y) \Vert} = \frac{1}{2}\). Finally \(f\) is not differentiable.

We also have \[\frac{\partial g}{\partial x}(x,y) = \frac{y^3}{(x^2+y^2)^{\frac{3}{2}}}, \frac{\partial g}{\partial x}(0,y) = \text{sign}(y)\] which proves that \(\frac{\partial g}{\partial x}\) is not continuous at the origin avoiding any contradiction with **theorem 1**.

### A function having directional derivatives along all directions which is not differentiable

We prove that \(h\) defined by

\[h(x,y)=\begin{cases}\frac{x^2 y}{x^6+y^2} & \text{ if } (x,y) \ne (0,0)\\

0 & \text{ if }(x,y) = (0,0)\end{cases}\] has directional derivatives along all directions at the origin, but is not differentiable at the origin.

First of all, \(h\) is a rational fraction whose denominator is not vanishing for \((x,y) \neq (0,0)\). Hence \(h\) is continuously differentiable for \((x,y) \neq (0,0)\). Let’s have a look to the directional derivatives at the origin. Let’s fix \(\mathbf{v} = (\cos \theta, \sin \theta)\) with \(\theta \in [0, 2\pi)\). For \(t \neq 0\), we have \[\frac{h(t \cos \theta, t \sin \theta) – h(0,0)}{t}= \frac{ \cos^2 \theta \sin \theta}{t^4\cos^6 \theta + \sin^2 \theta}\] which goes to \(0\) as \(t \to 0\) whatever the value of \(\theta\). Therefore, \(h\) has directional derivatives along all directions at the origin.

However, \(h\) is not differentiable at the origin. In fact \(h\) is not even continuous at the origin as we have \[h(x,x^3) = \frac{x^2 x^3}{x^6 + (x^3)^2} = \frac{1}{x}\] for \(x \neq 0\).

## 2 thoughts on “Differentiability of multivariable real functions (part1)”