Can functions be differentiable on sets with empty interiors? As a simple example, suppose we have a function $f: \mathbb{R}^3 \to \mathbb{R}$ defined on the set (and taking $+\infty$ everywhere else),
$$\{x \in \mathbb{R}^3| x_1 \in [-1, 1], x_2 \in [-1, 1], x_3 = 0\}$$
The set has no interior but a relative interior given by $(-1,1) \times (-1,1) \times \{0\}$.
Similarly, consider sets such as $\{x \in \mathbb{R}^3| \langle e, x\rangle = 1, x_i \geq 0\}$, where $e$ is the one-vector. Once again, it has no interior, but has a relative interior relative to the hyperplane $\langle e, x \rangle = 1$ given by $\{x \in \mathbb{R}^3| \langle e, x\rangle = 1, x_i > 0\}$,
Example functions could include:
$f(x) = \langle x, x \rangle$ for the first set
$f(x) = -\langle e, \ln(x) \rangle$ for the latter set
Are such function differentiable on such sets (i.e. the gradient exists)? If not, why? Can't seem to find any resource on this.
Edited per comment: Also, is it problematic if I were to pretend that the function was defined on the whole space, take the gradient there, and restrict it to the relative interior? For example, consider $f(x) = \langle x, x \rangle$ defined on the set $[-1, 1]^2 \times \{0\}$. What is wrong if I were to take the gradient as usual, $\nabla f(x) = 2 x$ and define it on the relative interior of the same set $(-1, 1)^2 \times \{0\}$?
 A: You can parametrize such sets and then consider the differentiability with respect to the parameters. The differentiability property will be invariant with respect to diffeomorphisms: if two parametrizations are related by a diffeomorphism (that is, by a differentiable bijection whose inverse is also differentiable), then a function differentiable with respect to one of the two parametrizations will be differentiable with respect to the other parametrization. In general, a parametrization can be any bijection. Some parametrizations may be more useful/natural than others -- e.g., parametrizations that are homeomorphisms with respect to the natural topologies would usually be better than parametrizations that are not homeomorphisms.
E.g., you can parametrize the set $S:=\{x\in\mathbb R^3\colon x_1+x_2+x_3=1,x_i>0\ \forall i\}$ by the parametrization
$$S_1\ni(s,t)\mapsto\phi(s,t):=(s,t,1-s-t)\in S$$
or, e.g., the parametrization
$$S_2\ni(s,t)\mapsto\psi(s,t):=(1-s-t,s,t)\in S,$$
where $S_1:=S_2:=\{(s,t)\in\mathbb R^2\colon s>0,t>0,s+t<1\}$. These two parametrizations are equivalent, in the sense that they are related by a diffeomorphism -- here, specifically, by the diffeomorphism
$$S_2\ni(s,t)\mapsto g(s,t):=(1-s-t,s)\in S_1$$
in the sense that $\psi=\phi\circ g$ and hence $\phi=\psi\circ g^{-1}$.
$\big($In the above example, the domains $S_1$ and $S_2$ of the two different parametrizations $\phi$ and $\psi$ of the same set $S$ were the same.
In general, though, the domains of different parametrizations of the same set may be different. Even in the above example, another parametrization of $S$ is
$$S_3\ni(s,t)\mapsto\rho(s,t):=(s,t-s,1-t)\in S,$$
where $S_3:=\{(s,t)\in\mathbb R^2\colon0<s<t<1\}\ne S_1$. The parametrization $\rho$ is then equivalent to the parametrizations $\phi$ and $\psi$.$\big)$
A function $f\colon S\to\mathbb R$ may then be called differentiable if the function $f\circ\phi\colon S_1\to\mathbb R$ is differentiable or, equivalently, if the function $f\circ\theta$ is differentiable, where $\theta$ is any parametrization of $S$ equivalent to $\phi$. Then, by the chain rule, we also have
$$(f\circ\psi)'=(f\circ\phi\circ g)'=(f\circ\phi)'\circ g';$$
here, at each point of $S_2$, $g'$ is a linear operator from $\mathbb R^2$ to $\mathbb R^2$, and $(f\circ\phi)'$ is a linear operator from $\mathbb R^2$ to $\mathbb R$ (that is, a linear functional).
For instance, the function $S\ni x\mapsto f(x):=x_1^2+x_2x_3$ will be differentiable, because the function $S_1\ni(s,t)\mapsto (f\circ\phi)((s,t))=s^2+t(1-s-t)$ is differentiable or, equivalently, because the function $S_2\ni(s,t)\mapsto (f\circ\psi)((s,t))=(1-s-t)^2+st[=(f\circ\phi\circ g)((s,t))]$ is differentiable.
For further reading, see e.g. differentiation on manifolds.
A: I think what you are looking for is the standard definition of once-differentiable manifold with boundary.
In order to define derivative, you need a normed vector space.  You need a vector space because differentiation is ${\Bbb R}$-linear.  You want to preserve the linearity because in a sense, differentiation is linearization.  You need the norm to take the limit.
The concept is generalized to manifolds by looking at the infinitesimal neighborhood of a point, the tangent space, which is a vector space.
As LSpice commented, your examples are manifolds with boundary.  The boundary is itself of a manifold one dimension lower, so you can define derivative there.
You can also consider a boundary point as part of the whole space.  There your "tangent space" is only half of a vector space.  You can generalize linearity here also, if you like.
Finally, manifolds are define by charts and you want to make sure that your differentiation operator is defined consistently across the charts.  This means that the transition maps should be differentiable.
