[Tex/LaTex] How to do a simple TikZ picture of the golden ratio

tikz-pgf

I want to make a short article explaining the origin of the Golden Number (1+sqrt(5))/2 and I need to draw a very simple segment like the picture I've uploaded. Any suggestions?

Golden Ratio

Best Answer

Two TikZ suggestions.

enter image description here

\documentclass[tikz,border=4mm]{standalone}
\begin{document}

\begin{tikzpicture}
\pgfmathsetmacro\gratio{(1+sqrt(5))/2}
\def\lenB{2}
\path (0,0) node[coordinate](start){} ++(\gratio*\lenB,0)node[coordinate](a){} -- ++(\lenB,0)node[coordinate](b){};

\draw (start) --node[above] {$a$} (a) --node[above]{$b$} (b);

\draw [stealth-stealth] ([yshift=-9pt]start) --node[fill=white,inner ysep=0pt]{$a+b$} ([yshift=-9pt]b);

\foreach \n in {start,a,b}
  \draw (\n) ++(0,-2pt) -- ++(0,4pt);

\end{tikzpicture}
\end{document}

enter image description here

\documentclass[border=4mm,tikz]{standalone}

\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[decoration=brace]
\pgfmathsetmacro\gratio{(1+sqrt(5))/2}
\def\lenB{2}
\draw (0,0) node[coordinate](start){} -- ++(\gratio*\lenB,0)node[coordinate](a){} -- ++(\lenB,0)node[coordinate](b){};


\draw [decorate] ([yshift=-4pt]b) --node[below]{$a+b$} ([yshift=-4pt]start);
\draw [decorate] ([yshift=4pt]start) --node[above]{$a$} ([yshift=4pt]a);
\draw [decorate] ([yshift=4pt]a) --node[above]{$b$} ([yshift=4pt]b);

\foreach \n in {start,a,b}
  \draw (\n) ++(0,-2pt) -- ++(0,4pt);

\end{tikzpicture}
\end{document}
Related Question