differentiable function with all partial derivatives equal Let $n\ge 3$ and $f\colon\mathbb{R}^n\setminus \overline{B}(0,1)\to\mathbb{R}$ - differentiable with all partial derivatives equal.
Prove that there exists differentiable $g\colon\mathbb{R}\to\mathbb{R}$ such that $f(x)=g(x_1+\dots +x_n)$ for all $x=(x_1,\dots,x_n)\in \mathbb{R}^n\setminus \overline{B}(0,1)$.
Is it true for $n=2$ also?
 A: Put $e:=(1,1,\ldots,1)\in{\mathbb R}^n$. Then there is a scalar function $\phi: \>{\mathbb R}^n\to{\mathbb R}$ such that
$$\nabla f(x)=\phi(x)\>e\ .$$
Consider the hyperplane $$\pi_c\!: \quad e\cdot x=x_1+x_2+\ldots +x_n=c$$ and a curve
$$t\mapsto x(t)\in\pi_c\qquad(a\leq t\leq b)$$
in this hyperplane. Since $x'(t)\cdot e\equiv0$ the pullback $\hat f(t):=f\bigl(x(t)\bigr)$ satisfies
$$\hat f'(t)=\nabla f\bigl(x(t)\bigr)\cdot x'(t)=\phi\bigl(x(t)\bigr)\>e\cdot x'(t)=0\qquad(a\leq t\leq b)\ ,$$
hence $\hat f(b)=\hat f(a)$. 
It follows that $f$ is constant on each connected component of $\pi_c\cap\Omega$, whereby $\Omega:={\mathbb R}^n\setminus\bar B_1$. Locally we therefore have functions $g:\>{\mathbb R}\to{\mathbb R}$ such that 
$$f(x_1,x_2,\ldots, x_n)=g(x_1+x_2+\ldots+ x_n)\ .\tag{1}$$
In particular
$$g(t)=f(2,t-2,0\ldots,0)\qquad(t\in{\mathbb R})\ .$$
This shows that these functions $g$ are differentiable.
When $n\geq3$ then the sets $\pi_c\cap\Omega$ are connected, hence there is a single globally defined function $g$ such that $(1)$ holds. If $n=2$, however, the $\pi_c$ are lines $x_1+x_2=c$ ,  and when $|c|\leq\sqrt{2}$ the ball $\bar B_1$ intersects such a line in a nonempty interval. It follows that $\pi_c\cap\Omega$ is disconnected for these $c$. It is easy to construct an example of a smooth $f$ which is $\equiv0$ when $|x_1+x_2|\geq\sqrt{2}$ and takes different values on the halflines making up $\pi_c\cap\Omega$ when $|c|<\sqrt{2}$. Take, e.g.,
$$f(x_1,x_2):=\left\{\eqalign{&{\rm sgn}(x_2-x_1)\bigl(2-(x_1+x_2)^2\bigr)^2\qquad\bigl(|x_1+x_2|< \sqrt{2}\bigr)\cr &0\qquad{\rm (otherwise)}\cr}\right.$$
