If you have several of these expressions in your document, it's helpful to set up a macro that collects and organizes the elements. In the code below, I define a macro named \myfunc for this purpose; it takes five arguments: the function name, the domain, the codomain, and terms for the second row.

\documentclass{article}
\usepackage{array,amsfonts}
\newcommand\myfunc[5]{%
\begingroup
\setlength\arraycolsep{0pt}
#1\colon\begin{array}[t]{c >{{}}c<{{}} c}
#2 & \to & #3 \\ #4 & \to & #5
\end{array}%
\endgroup}
\begin{document}
The function $\myfunc{f}{\mathbb{N}}{\mathbb{N}}{x}{x^2}$ is known \dots
\bigskip
The function $\myfunc{g}{\mathbb{R}}{\mathbb{C}}{x}{\sqrt{x}}$ is called \dots
\end{document}
\mapstoin the lower row see, e.g., my answer -- and the material in the addendum, in particular -- to the query Writing a nice function. – Mico Jan 30 '16 at 20:36