Samuel Ireson

Learning TikZ - Episode 6

Thu Apr 25 2024
4 min read

We'll walk through how I made a figure to visualise Riemann surfaces.

Contents

Introduction

TikZ is a LaTeX library which allows you to draw diagrams, figures, graphs, and anything else which you can think up. It’s my go-to for drawing complex diagrams because of it’s reliance on declarative nature. Also, the implementation of the commands is very neat, and natural.

Setup

The minimal setup for creating a TikZ figure is as follows,

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
    % TikZ goes here.
\end{document}

which will output a .pdf file, with minimal dimensions. You can include the graphics generated in a master file with the \includegraphics{} command.

Figure

We will be thinking about Riemann surfaces in the way that Bernhard Riemann first did in 1854 - as suitable domains for multivalued functions. We’re going to use some neat TikZ tricks, and hopefully end up with a figure which successfully puts the point across. We’ll be thinking about the square root function,

 ⋅ :C→C:z↦z\sqrt{\,\cdot\,}:\mathbb{C} \to \mathbb{C}:z \mapsto \sqrt{z}

which in first courses in complex analysis is considered in branches to account for the multiple branches of the logarithm.

In drawing the figure, we’ll be using the intersections library, which can be loaded with

\usetikzlibrary{intersections}

in the preamble.

To begin with, we’ll draw two arcs, using a handy trick to center the arcs on specific points, which we define explicitly.

\coordinate (t) at (0,0);
\coordinate (b) at ($ (t) + (0,-2) $);

\filldraw[fill=white] ([shift=(-60:2)]b) arc (-60:220:2);
\filldraw[fill=white] ([shift=(-60:2)]t) arc (-60:220:2);

Before, looking at what the figure with these commands, we make a global change to the tikzpicture, altering the value of the y coordinate, which will change the perspective in a useful manner.

\begin{tikzpicture}[y = {(0,0.25)}]

With this change, the figure initially looks like,

Initial drawing

We then draw two more paths which start at the endpoints of the arcs we just draw, and cross in a manner which will be useful in explaining the concept we are aiming to portray.

\draw[rounded corners=2mm, name path = curve1] ([shift=(220:2)]b) arc (220:240:2) -- ([shift=(-100:2)]t) arc (-100:-60:2);
\draw[rounded corners=2mm, name path = curve2] ([shift=(220:2)]t) arc (220:240:2) -- ([shift=(-100:2)]b) arc (-100:-60:2);

Initial drawing, connected

Since we named each of these curves, we will be able to use the interesections library to find their intersection, and this will help us in drawing a line from the origin of the top disc to the point where the discs intersect.

\fill (0,0) circle (0.05) node[above]{$ O $};
\draw[name intersections={of=curve1 and curve2}] (0,0) -- (intersection-1);
\fill[name intersections={of=curve1 and curve2}] (intersection-1) circle (0.05) 
	node[right=0.2cm]{$ 0 $} 
	node[left=0.2cm]{$ \pi $} 
	node[below=0.2cm]{$ 2 \pi $};

With a label at the intersection

We can easily add similar labels for other relevant points of the discs using a coordinate system relative to the points which we defined at the beginning.

\fill (-20:2) circle (0.05) node[right=0.1cm]{$ \frac{\pi}{4} $};
\fill (70:2) circle (0.05) node[above]{$ \frac{\pi}{2} $};
\fill (160:2) circle (0.05) node[left]{$ \frac{3\pi}{4} $};
\fill ([shift=(-20:2)]b) circle (0.05) node[right=0.1cm]{$ \frac{5\pi}{4} $};
\fill ([shift=(160:2)]b) circle (0.05) node[left]{$ \frac{7\pi}{4} $};

With all labels

We draw and label a disc below to represent the codomain of the square root, and also label a specific point xx.

\begin{scope}[yshift = -2cm]
	\draw (0,0) circle (2);
	\fill (0,0) circle (0.05) node[above]{$ O $};
	\coordinate (x) at (-65:1);
	\fill (x) circle (0.05) node[right=0.1cm]{$ x $};
	\fill (-20:2) circle (0.05) node[right=0.1cm]{$ \frac{\pi}{2} $};
	\fill (70:2) circle (0.05) node[above]{$ \pi $};
	\fill (160:2) circle (0.05) node[left]{$ \frac{3\pi}{2} $};
	\fill (250:2) circle (0.05) node[above]{$ 0 $} node[below]{$ 2 \pi $};
\end{scope}

With a disc below

Finally, we use the intersections library again to draw a series of lines between the point xx, and the corresponding points in the domain ±x\pm\sqrt{x}.

\coordinate (-sqrt) at (-65:1);
\coordinate (sqrt) at ([shift=(-65:1)]b);
\fill (-sqrt) circle (0.05) node[above]{$ -\sqrt{x} $};
\fill (sqrt) circle (0.05) node[right]{$ \sqrt{x} $};
\path[name path = function] (x) -- (-sqrt);
\draw[name intersections={of=function and curve2}] (x) -- (intersection-1);
\draw[name intersections={of=function and curve2}, dotted] (intersection-1) -- (sqrt);
\draw[name intersections={of=function and curve1}] (sqrt) -- (intersection-1);
\draw[name intersections={of=function and curve1}, dotted] (intersection-1) -- (-sqrt);

This gives us the final figure.

Final figure

Conclusion

This is another figure which I used in my dissertation for university. If you’re interested in seeing all of the figures I made, or the project in general, you can find it on my GitHub.

Related posts