Why does the condition of a function being differentiable always require an open domain?
Solution 1:
Here is a motivating example. Say we have $f:[0,1)\rightarrow \mathbb{R}$. When should we call $f$ differentiable on $[0,1)$?
In particular, how should we determine if $f$ is differentiable at $0$? Even if we have that $f$ is differentiable on $(0,1)$, and that $$\lim_{h\rightarrow 0^+}\frac{f(h)-f(0)}{h}$$ exists, we have no way of determining anything about $$\lim_{h\rightarrow 0^-}\frac{f(h)-f(0)}{h}$$ since $f(x)$ is not defined for $x<0$.
We could simply say that $f$ is differentiable on $[0,1)$ if it is differentiable on $(0,1)$ and right differentiable at $0$. However, then if we took, for example, $f(x)=|x|$, we would find that $f$ is not differentiable at $0$ with domain $(-1,1)$ (or any open interval containing $[0,1)$), and yet $f$ is differentiable at $0$ on $[0,1)$. Intuitively, $f$ should be differentiable at $0$ either all the time or never, rather than only sometimes, so this would not be a very good definition.
Instead, we simply insist that $0$ be differentiable in the usual way at $x=0$, which requires $f$ be defined on an open neighborhood around $0$.
You can see where this is going. In general, if $f$ has domain $\mathcal{D}$, we want to call $f$ differentiable whenever $f$ is differentiable at every $d\in\mathcal{D}$, which requires that we can extend $f$ to include open neighborhoods around every $d$.
Solution 2:
The problem is that our definition of differentiability at a point requires the function to be defined on an open neighborhood of that point. So technically, we don't even know what it means for a function to be differentiable at a boundary point.
Right now, we don't have any information about the set $A \subseteq \mathbb{R}^n$, which is problematic. Naturally, we might want to define $f:A \to \mathbb{R}^m$ to be differentiable at $x \in A$ if there is some linear transformation $Df_x$ such that for all $h$ where $x+h \in A$, $$\lim_{h \to 0} \frac{f(x+h) - (f(x)+Df_x (h))}{h} = 0.$$
But this definition is problematic when $A$ is not an $n$-dimensional manifold. For example, take $$f(x,y) = \frac{xy^2}{x^2+y^2}$$ (with $f(0,0)=0$). We don't consider $f$ to be differentiable at the origin. But if $A$ is any line through the origin, we will find (with our putative definition above) that $f$ is now differentiable at the origin, when we probably don't want to consider that to be the case.
Now, if $A$ were an $n$-manifold, then our idea for defining the derivative of the function on the boundary will work, because locally at the boundary point, the boundary of $A$ looks like a plane cutting through the boundary point, and so we "see half the space," and the definition above would be equivalent to $f$ being able to be differentiably extended to an open set containing $A$.