% This picture represents the definition of a smooth manifold
% (C) Thiago Brevidelli
\begin{tikzpicture}
  % The manifold
  \begin{scope}[shift={(-0.5, 0)}]
    % The frontire
    \draw (-4, 2) to[relative, out=20, in=160] 
          ( 2, 0) to[relative, out=20, in=160] 
          ( 4, 3) to[relative, out=-20, in=-160] 
          cycle;
    \draw (-4, 2) node[below]{$M$};

    % The open sets of the manifold and their intersection
    \begin{scope}[shift={(1, 2.2)}]
      \draw (-0.5, 0) ellipse (0.7 and 0.5);
      \draw (-1.2, 0) node[right]{$U$};
      \draw (0.5, 0) ellipse (0.7 and 0.5);
      \draw (1.2, 0) node[left]{$V$};
      \clip (-0.5, 0) ellipse (0.7 and 0.5);
      \draw[pattern=north west lines] (0.5, 0) ellipse (0.7 and 0.5);
    \end{scope}
  \end{scope}

  % The cards
  \draw[->] (-0.7, 1.7) to[relative, out=-20, in=-160] 
            node[left]{$\varphi_U$} (-2, -0.7);
  \draw[->] (1.7, 1.7) to[relative, out=20, in=160] 
            node[right]{$\varphi_V$} (2, -0.7);

  % The corresponding open sets in euclidian space
  \begin{scope}[shift={(0, -1.5)}]
    % The open sets
    \draw (-2, 0) ellipse (1 and 0.6) (2, 0) ellipse (1 and 0.6);
    \draw (-3, 0.5) node[above]{$\varphi_U(U)$};
    \draw (3, 0.5) node[above]{$\varphi_V(V)$};

    % The intersections
    \begin{scope}
      \clip (-2, 0) ellipse (1 and 0.6);
      \draw[pattern=north west lines] (-0.5, 0) ellipse (1 and 0.6);
    \end{scope}
    \begin{scope}
      \clip (2, 0) ellipse (1 and 0.6);
      \draw[pattern=north west lines] (0.5, 0) ellipse (1 and 0.6);
    \end{scope}

    % The diffeomorphism
    \draw[->] (-0.9, 0) -- 
              node[above]{$\varphi_V \circ \varphi_U^{-1}$} (0.9, 0);
  \end{scope}
\end{tikzpicture}

