# Intersecting and drawing of intersection

I am trying to replicate these diagrams (Samuelson-rule) in Latex. I haven't understood how the calculate the intersection of graphs and how the draw links between two diagrams. This is my result so far.

\begin{figure}[h!]
\centering
\begin{tikzpicture}[domain=0:6, range=4:5, thick]
\pgfmathsetlengthmacro{\lengthXaxis}{6cm}
\pgfmathsetlengthmacro{\lengthYaxis}{5cm}

\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x,\textcolor{cyan}{x_2}}$};
\draw [->] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{\textcolor{green}{y}}$};

\draw [name path global=f1a] (\radiusArcFigureOne,0)
arc [
start angle=0,
end angle=90,
]
;
\draw[name path global=f1b, thick, color=purple, domain=2.5:8, shift={(-2,.7)}]
plot (\x,{25*exp(-.7*\x-.25)+.7}) node[right] {$\bar{u}_2$}
;

\begin{scope}[yshift=-6cm]
\draw [->, name path global=f2xline] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{y}$};

\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x_1}$};

\draw[name path global=f5, thick, color=cyan, domain=4:8, shift={(-2,-.067)}]
plot (\x,{15*exp(-.5*\x-.35)+.75}) node[right] {$u^{\ast}_1$};
\end{scope}

\begin{scope}[yshift=-12cm]
\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x_2}$};

\draw [->, name path global=f3xline] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{y}$};

\draw[name path global=f3a, thick, color=purple, domain=3:5.5, shift={(-.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\draw[name path global=f3b, thick, color=purple, domain=3:5.5, shift={(-1.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\draw[name path global=f3c, thick, color=purple, domain=3:5.5, shift={(.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\end{scope}

\path [name intersections={of=f1a and f1b, by={is f1 left, is f1 right}}];

\path [name path=left vline]% vertical line
(is f1 left) --
(is f1 left|-current bounding box.south)
;

\path [name intersections={of=f2xline and left vline, by=is f2xline left vline}];

\draw [dotted] (is f1 left) -- (is f2xline left vline);

\path [name path=right vline]% s.o.
(is f1 right) --
(is f1 right|-current bounding box.south)
;

\path [name intersections={of=f2xline and right vline, by=is f2xline right vline}];

\draw [dotted] (is f1 right) -- (is f2xline right vline);

\draw [name path global=f6] let
\p1 = ($(is f2xline left vline) - (is f2xline right vline)$),
\n2 = {veclen(\x1,\y1)/2}
in
(is f2xline right vline)

arc [start angle=0, end angle=180, x radius=\n2, y radius=2*\n2/3]
;

\path [name intersections={of=f5 and f6, by=f6}];

\end{tikzpicture}
\caption{Samuelson-rule}
\end{figure}


It should look like this

I just continued in the way you started to get

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}[domain=0:6, range=4:5, thick]
\pgfmathsetlengthmacro{\lengthXaxis}{6cm}
\pgfmathsetlengthmacro{\lengthYaxis}{5cm}

\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x,\textcolor{cyan}{x_2}}$};
\draw [->] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{\textcolor{green}{y}}$};

\draw [name path global=f1a] (\radiusArcFigureOne,0)
arc [
start angle=0,
end angle=90,
]
;
\draw[name path global=f1b, thick, color=purple, domain=2.5:8, shift={(-2,.7)}]
plot (\x,{25*exp(-.7*\x-.25)+.7}) node[right] {$\bar{u}_2$}
;

\begin{scope}[yshift=-6cm]
\draw [->, name path global=f2xline] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{y}$};

\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x_1}$};

\draw[name path global=f5, thick, color=cyan, domain=4:8, shift={(-2,-.067)}]
plot (\x,{15*exp(-.5*\x-.35)+.75}) node[right] {$u^{\ast}_1$};
\end{scope}

\begin{scope}[yshift=-12cm]
\draw [->] (0,0) -- (0,\lengthYaxis) node[above] {$\pmb{x_2}$};

\draw [->, name path global=f3xline] (0,0) -- (\lengthXaxis,0) node[right] {$\pmb{y}$};

\draw[name path global=f3a, thick, color=purple, domain=3:5.5, shift={(-.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\draw[name path global=f3b, thick, color=purple, domain=3:5.5, shift={(-1.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\draw[name path global=f3c, thick, color=purple, domain=3:5.5, shift={(.5,-.4)}]
plot (\x,{25*exp(-.7*\x-.25)+.7});
\end{scope}

\path [name intersections={of=f1a and f1b, by={is f1 left, is f1 right}}];

\path [name path=left vline]% vertical line
(is f1 left) --
(is f1 left|-current bounding box.south)
;

\path [name intersections={of=f2xline and left vline, by=is f2xline left vline}];

\draw [dotted] (is f1 left) -- (is f2xline left vline);

\path [name path=right vline]% s.o.
(is f1 right) --
(is f1 right|-current bounding box.south)
;

\path [name intersections={of=f2xline and right vline, by=is f2xline right vline}];

\draw [dotted] (is f1 right) -- (is f2xline right vline);

\draw [name path global=f6] let
\p1 = ($(is f2xline left vline) - (is f2xline right vline)$),
\n2 = {veclen(\x1,\y1)/2}
in
(is f2xline right vline)
arc [start angle=0, end angle=180, x radius=\n2, y radius=2*\n2/3]
coordinate[midway] (j1);

\path [name intersections={of=f5 and f6, by=i1,total=\t}];
%\pgfextra{\typeout{\t}};
\path [name path=iline]% s.o.
(i1|-current bounding box.north) --
(i1|-current bounding box.south) ;

\path [name intersections={of=f1a and iline, by=i2},
name intersections={of=f1b and iline, by=i3},
name intersections={of=f3a and iline, by=i4}];
\draw [dotted] (i2|-0,-12) |- (i2-|0,0)
foreach \X in {1,3,4} {(i\X) -- (i\X-|0,0)};

\path [name path=jline]% s.o.
(j1|-current bounding box.north) --
(j1|-current bounding box.south) ;
\path [name intersections={of=f1b and jline, by=j2}];
\draw [dotted] (j2|-0,-6) |- (j2-|0,0);
\end{tikzpicture}
\caption{Samuelson-rule}
\end{figure}
\end{document}


• Thank you very much! Could you please help me to understand how you did it. How do you calculate the intersection and how do you draw the dotted lines? I just don't get it. I am very new to tikzpicture – Eduard Dec 18 '19 at 15:31
• @Eduard I just continued what you did: compute an intersection, construct a vertical path that runs from south to north through the intersection, and then compute the intersections of the vertical path with the plots to do something with them. – Schrödinger's cat Dec 18 '19 at 15:41