# Suppose all partial derivatives of $f$ exist at $x_0$; is $f$ continuous at $x_0$?

Consider $f : C \to \mathbb{R}$ with $C \subset \mathbb{R}^n$ being open:

1. Suppose $f$ is differentiable at $\mathbf{x}_0 \in C$. Is $f$ continuous at $\mathbf{x}_0$? Why?

2. Suppose all partial derivatives of $f$ exist at $\mathbf{x}_0 \in C$ but $\nabla f = 0$. Is $f$ continuous at $\mathbf{x}_0$? Why?

3. Suppose all partial derivatives of $f$ exist at $\mathbf{x}_0 \in C$ and $\nabla f \ne 0$. Is $f$ continuous at $\mathbf{x}_0$? Why?

The answer to (1) is clear: yes, because differentiability is sufficient for continuity. This follows from the definition of differentiability (is this a sufficient answer?).

For (2) and (3) however, I am stumped. I remember from real analysis that when all partial derivatives exist and are continuous, then the function is differentiable (and differentiability implies continuity). However, I don't know if the partials are continuous. I only know that in one case $\nabla f \ne 0$ and in another case $\nabla f = 0$.

Edit: From taking a look at this question, it seems like some counterexamples (where the directional derivatives exist and equal $0$) show the answers to (2) and (3) are no and no. I have produced some counterexamples and posted them as an answer below. Please let me know if they're OK. Thanks!

Edit 2: Marc van Leeuwen mentioned my answer may not be correct because of some technicalities regarding the gradient. Please take a look and let us know what you think. Thanks!

2. Not necessarily. Consider the function $$f(x,y)=\left\{ \begin{array}{lr} 0 & x=0\textrm{ or }y=0\\ 1 & otherwise \end{array} \right.$$ Since $\frac{\partial f}{\partial x}(0,0)= \lim_{h \to 0} \frac{f(h,0)-f(0,0)}{h}=\lim_{h \to 0} \frac{0}{h}=0$ and similarly $\frac{\partial f}{\partial y}(0,0)=0$, then $$\nabla f(0,0) = \left(\frac{\partial f}{\partial x}(0,0),\frac{\partial f}{\partial y}(0,0)\right)=(0,0)$$ However, since $\lim_{x \to 0} f(x,x) = 1 \ne 0=f(0,0)$, then $f$ is not continuous at $(0,0)$.
3. Not necessarily. Consider the function $$f(x,y)=\left\{ \begin{array}{lr} x+y & x=0\textrm{ or }y=0\\ 1 & otherwise \end{array} \right.$$ Since $\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}{h}=1$ and similarly $\frac{\partial f}{\partial y}(0,0)=1$, then $$\nabla f(0,0) = \left(\frac{\partial f}{\partial x}(0,0),\frac{\partial f}{\partial y}(0,0)\right)=(1,1)$$ However, since $\lim_{x \to 0} f(x,x) = 1 \ne 0=f(0,0)$, then $f$ is not continuous at $(0,0)$.
• It would seem to me that the definition of $\nabla f$ presupposes at least that all the directional derivatives exist (not just those along the coordinate directions), and moreover correspond to a linear function (scalar product with a fixed vector). In your examples 2,3, this is not the case. – Marc van Leeuwen Sep 17 '14 at 5:06
• Are you saying the gradient of $f$ at $(x,y)$ only makes sense in the context of $f$ being differentiable at $(x,y)$? You might be correct; it has been a while since I've taken analysis. Please feel free to correct my answer, and/or post an alternate solution. – Mathemanic Sep 17 '14 at 5:12
• If you want to define the gradient by the Riesz representation theorem (i.e. the unique vector associated to the differential), then $f$ must be differentiable. But in $\mathbb{R}^n$ we can merely define the gradient with respect to a particular basis, and the minimal requirement becomes that $f$ be differentiable along the vectors of this basis. I agree that this is a somehow bad definition since it is not intrinsic, but it can be a shorthand in some circumstances. – Siminore Sep 17 '14 at 8:13
• What I said is just that the definition I found on Wikipedia supposes that all directional derivatives exist, which is weaker than being differentiable at the point, but a lot stronger than just having partials in the coordinate directions. Personally I would prefer simply requiring being differentiable at $(x,y)$. In any case knowing the precise definition is essential for answering this question. – Marc van Leeuwen Sep 17 '14 at 8:39