Find a function from $\mathbb{R}^n$ to $\mathbb{S^n}$ with the following condictions I need to show the existence of a $C^\infty$ function $f:\mathbb{R}^n\rightarrow\mathbb{S}^n$ with the following properties:

*

*$f(B(0,1))=\mathbb{S}^n\setminus\{p\}$, where $p=(0,...,0,1)$

*$f|_{B(0,1)}$ is a local diffeormorphism

*$f(\mathbb{R}^n\setminus B(0,1))=\{p\}$
My first thought was: take the stereographic projection $\pi:\mathbb{S}^n\setminus\{p\}\rightarrow\mathbb{R^n}$ and the expansion $r:B(0,1) \rightarrow \mathbb{R}^n$ , $r(x)=\frac{x}{\sqrt{1-||x||^2}}$, both $C^\infty$ diffeomorphisms on their respective domains (and with computable inverses). Now we can take $g=\pi^{-1}\circ r $ to create a $C^\infty$ diffeomorphism from $B(0,1)$ to $\mathbb{S^n}$ and create the extension $f(x)=g(x)$ if $x\in B(0,1)$ and $f(x)={p}$ if $x\in\mathbb{R^n}\setminus B(0,1)$. It readily follows that $f$ is continous and have the three cited properties. However, I don't know if $f$ is $C^\infty$: it is on $\mathbb{R^n}\setminus \overline{B(0,1)}$ and on $B(0,1)$ but we don't know if it is on $\partial B(0,1)$. Actually, I suspect it is not smooth on the boundary of $B(0,1)$ because if we compute $g$ we get:
$$g(x)=\left(2\frac{1-||x||^2}{\sqrt{1-||x||^2}}x,2||x||^2-1 \right) $$
which does not look like it has a smooth extension because the derivative of $\frac{1-||x||^2}{\sqrt{1-||x||^2}}$ goes to infinity when $x$ approaches the boundary.
Right now, I'm trying two ideas (that may be equivalent, in some way):

*

*Try to "smooth" the above functions with higher exponents so that the final function has smooth extension

*Take some "bump" function or partition of unity, let's say $\rho_i$ (maybe define $g$ on $B(0,1+\epsilon)$ instead of $B(0,1)$), but it is very hard to control $\rho_i g$ outside $B(0,1)$ (but on $\text{supp }\rho_i$) such that $f(x)=p$
If anybody has any idea I would be greateful
 A: Let, for $x \in \mathbb{R}^n$, $\pi_+(x)$ be the second intersection with $S^n$ of the line going through $(x,0)$ and $-p$. Let $\pi_-(x)$ be the same for the line between $(x,0)$ and $p$.
So the OP basically asks for two smooth functions $f_+: \mathbb{R}^n \backslash \{0\} \rightarrow \mathbb{R}^n$, $f_-: B(0,1) \rightarrow \mathbb{R}^n$, such that $f_-$ is a surjective local diffeomorphism, $\pi_- \circ f_-=\pi_+ \circ f_+$, and $f_+(\{|x| \geq 1\})=\{0\}$.
Note that $\pi_+(y)=\left(\frac{2y}{1+|y|^2},\frac{1-|y|^2}{1+|y|^2}\right)$ while $\pi_-(y)=\left(\frac{2y}{1+|y|^2},\frac{|y|^2-1}{1+|y|^2}\right)$, thus $\pi_-(x)=\pi_+(y)$ iff $x=y/|y|^2$.
So we look for solutions of the form $f_+(y)=\psi(|y|)y/|y|$.
The condition is thus that $\psi: (0,\infty) \rightarrow (0,\infty)$ is surjective, smooth, with negative derivative on $(0,1)$, vanishes on $[1,\infty)$, and that $1/\psi(r)$ extends to a smooth function with positive derivative at $r=0$.
So with $\psi(r)=0$ if $r \geq 1$ and $\psi(r)=\frac{1}{r}\exp(-(1-r)^{-2})$ for $0 < r <1$, this should work.
