Draw arrows to show multiplication pattern (distributive property)

Just a more beautiful solution with PSTricks.

\documentclass[preview,border=1cm,12pt,varwidth]{standalone}
\usepackage{pst-node,amsmath}
\psset{nodesep=2pt,linearc=2pt,arrows=->,linecolor=blue,arrowinset=0}
\def\lbl#1{\ncput*{\text{\tiny #1}}}
\begin{document}
\abovedisplayskip=0pt\relax% don't use this line in your production
\[
(\rnode{A}{a}+\rnode{B}{b})(\rnode{C}{c}+\rnode{D}{d})=\ldots
\ncbar[angle=90,offsetA=-1pt]{A}{C}\lbl{1}
\ncbar[angle=90,offsetA=1pt,arm=16pt]{A}{D}\lbl{2}
\ncbar[angle=-90,offsetA=1pt]{B}{C}\lbl{3}
\ncbar[angle=-90,offsetA=-1pt,arm=16pt]{B}{D}\lbl{4}
\]
\end{document}

enter image description here


The following code maybe a starting point for you:

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\newcounter{source}
\newcommand\source[1]{%
    \tikz[remember picture,baseline,inner sep=0pt] {%
        \node [name=source-\thesource,anchor=base]{$#1$};
    }%
    \setcounter{target}{0}
    \stepcounter{source}
}

\newcounter{target}
\newcommand\target[1]{%
    \tikz[remember picture,baseline,inner sep=0pt] {%
        \node [name=target-\thetarget,anchor=base]{$#1$};
    }%
    \setcounter{source}{0}
    \stepcounter{target}%
}
\newcommand\drawarrows{
    \tikz[remember picture, overlay, bend left=45, -latex] {
    \foreach \j [evaluate=\j as \m using int(\j)] in {1,...,\thesource}{
        \foreach \i [evaluate=\i as \n using int(\i-1)] in {1,...,\thetarget} {
            \draw [red](source-0.north) to (target-\n.north) coordinate (UP);
          }
       \node [red] at (UP) [above] {1}; 
    }
}

 \tikz[remember picture, overlay, bend left=-45, -latex] {
    \foreach \j [evaluate=\j as \m using int(\j)] in {1,...,\thesource}{
        \foreach \i [evaluate=\i as \n using int(\i-1)] in {1,...,\thetarget} {
            \draw [blue](source-1.south) to (target-\n.south) coordinate (DOWN) ;
         }
        \node [blue] at (DOWN) [below] {2};
    }
}
}



\begin{document}

\begin{equation}
(\source{a}+\source{4})(\target{b}+\target{3})=\mbox{\drawarrows}
\end{equation}

\end{document}

Output:

enter image description here

Update: Labeling each arrow:

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz,pgfplots}

\newcounter{source}
\newcommand\source[1]{%
    \tikz[remember picture,baseline,inner sep=0pt] {%
        \node [name=source-\thesource,anchor=base]{$#1$};
    }%
    \setcounter{target}{0}
    \stepcounter{source}
}

\newcounter{target}
\newcommand\target[1]{%
    \tikz[remember picture,baseline,inner xsep=0pt] {%
        \node [name=target-\thetarget,anchor=base]{$#1$};
    }%
    \setcounter{source}{0}
    \stepcounter{target}%
}
\newcommand\drawarrows{
    \tikz[remember picture, overlay, bend left=45, -latex] {
    \foreach \j [evaluate=\j as \m using int(\j)] in {1,...,\thesource}{
        \foreach \i [evaluate=\i as \n using int(\i-1)] in {1,...,\thetarget} {
            \draw [red](source-0.north) to (target-\n.north) ;
              \node [red] at ([xshift=-5mm]target-\n.north) [above=2mm] {\i};
          }

    }
}

 \tikz[remember picture, overlay, bend left=-45, -latex] {
    \foreach \j [evaluate=\j as \m using int(\j)] in {1,...,\thesource}{
        \foreach \i [evaluate=\i as \n using int(\i-1)] in {1,...,\thetarget} {
            \draw [blue](source-1.south) to (target-\n.south)  ;
      \pgfmathsetmacro{\ii}{\i+2)};
         \node [blue] at ([xshift=-2mm]target-\n.south) [below=2mm] {\pgfmathprintnumber \ii};
    }
}
}}



\begin{document}

\begin{equation}
(\source{a}+\source{4})(\target{b}+\target{3})=\mbox{\drawarrows}
\end{equation}

\end{document}

and the output:

enter image description here


Another solution with pstricks, compilable with pdflatex, if you launch it with the --enable-write18 switch if you're under MiKTeX, or -shell-escape (TeX Live, MacTeX). Alternatively, you can compile with XeLaTeX:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

\begin{document}

\Large
\begin{postscript}
  \begin{align*}
    (\rnode{X1}{2x}+\rnode{Y1}{\smash[b]{3y}})(\rnode{X2}{4x}+\rnode{Y2}{5y}) & = (2x)(4x)+(2x)(5y)+(3y)(4x)+(3y)(5y) \\
                                                                              & = 8x²+10xy+12xy+15y² \\
                                                                              & = 8x²+22xy+15y²
  \end{align*}
  \psset{angle=90,nodesep=2pt, arrows=<->, arrowinset=0.2}
  \ncbar[arm=15pt]{Y1}{Y2}\ncbar[border=1.5pt]{X1}{X2}
  \psset{angle=-90,nodesep=4pt}
  \ncbar{X1}{Y2}\ncbar[arm=8pt]{Y1}{X2}
\end{postscript}

\end{document} 

enter image description here