% This picture represents the definition of a smooth map between manifolds
% (C) Thiago Brevidelli
\begin{tikzpicture}
  % The manifolds
  \begin{scope}[shift={(-2, 0)}]
    \draw  (-1.5, -0.5) to[relative, out=20,  in=160] 
          +(   2,    0) to[relative, out=20,  in=160] 
          +(   1,    1) to[relative, out=-20, in=-160] 
          +(  -2,    0) to[relative, out=-20, in=-160] 
           cycle;
    \draw (0.5, -0.5) node[right]{$M$};
  \end{scope}
  \begin{scope}[shift={(2, 0)}]
    \draw  (-1.5, -0.5) to[relative, out=20,  in=160] 
          +(   2,    0) to[relative, out=20,  in=160] 
          +(   1,    1) to[relative, out=-20, in=-160] 
          +(  -2,    0) to[relative, out=-20, in=-160] 
           cycle;
    \draw (0.5, -0.5) node[right]{$N$};
  \end{scope}

  % The functions
  \draw[->] (-1,  0.9) to[out=30, in=150] node[above]{$f$} (1, 0.9);
  \draw[->] (-1, -1.7) to[out=30, in=150] 
  node[above]{$\psi \circ f \circ \varphi^{-1}$} (1, -1.7);
  \draw[->] (-2, -0.7) -- node[left]{$\varphi$} +(0, -1);
  \draw[->] ( 2, -0.7) -- node[left]{$\psi$} +(0, -1);

  % The open sets in euclidian space
  \draw[dashed] (-2, -3) node{$\varphi(U)$} ellipse (1 and 0.5);
  \draw[dashed] ( 2, -3) node{$\psi(V)$} ellipse (1 and 0.5);
  \draw (-3.5, -4) node[left]{$\mathbb{R}^m$} rectangle +(3, 2);
  \draw ( 0.5, -4) node[left]{$\mathbb{R}^n$} rectangle +(3, 2);
\end{tikzpicture}
