# To draw arrows in an efficient way

I am trying to reproduce the image below in latex, but I am having a bit of difficulty to draw the arrows. Is there a an easy, less time consuming way to obtain this?

An easy way is using tikzmark. You may have a look at my beamer slide. (I will add more when I have time)

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{frame}[t]{Function}
\begin{definition}
A function $f$ is a rule that assigns each element $x$ in a set $X$, called the domain, to \alert{exactly one element},
called $y=f(x)$, in a set $Y$, called the range.
\end{definition}
\begin{align*}
\tikzmarknode{f}{f} :\tikzmarknode{X}{X}&\longrightarrow \tikzmarknode{Y}{Y}\\
x&\longmapsto y=f(x).
\end{align*}
\begin{tikzpicture}[overlay,remember picture]
\draw[magenta,stealth-] (X.north)++(90:.1)--+(90:.3) node[above]{domain};
\draw[magenta,stealth-] (Y.north east)++(90:.1)--+(30:.5) node[right]{range};
\draw[magenta,stealth-] (f.north west)++(90:.1)--+(150:.5) node[left]{function};
\end{tikzpicture}
\end{frame}
\end{document}