# TikZ mathematics examples

> Mathematics figures in TikZ with code: geometry, graph theory, calculus, linear algebra and tensors, probability distributions and numerical methods.

URL: https://www.labcanvas.com/tikz/examples/mathematics

Thirty-six figures across geometry (the unit circle, incircle and circumcircle, the arbelos, a Koch snowflake), topology (a pair of pants), graph theory (a Hamiltonian cycle, K 3,3, the Königsberg bridges), functions and calculus (Taylor polynomials of sine, the area under x², branch cuts, a saddle surface), linear algebra and tensors, probability distributions and numerical methods such as a five-point stencil, a Q1 finite element basis function and conjugate gradient steps.

Fourteen use pgfplots for axes and function plots and three use tikz-3dplot for 3D views; the others rely on TikZ’s own tools, such as polar coordinates, `calc` for computed points, and the `angles` and `quotes` libraries for marked angles.

## Geometry

- **Fundamental domain of the modular group** (Geometry): MIT licence, © Janosh Riebesell and contributors. Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/torus-fundamental-domain/torus-fundamental-domain.tex. Code: https://www.labcanvas.com/tikz-library/code/fundamental-domain-of-the-modular-group.tex
- **Cylinder to plane (conformal map)** (Geometry): MIT licence, © Janosh Riebesell and contributors. Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/cylinder-to-plane/cylinder-to-plane.tex. Code: https://www.labcanvas.com/tikz-library/code/cylinder-to-plane-conformal-map.tex
- **Unit circle: sine and cosine** (Geometry): MIT licence, © Petar Veličković. Source: https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Coordinate%20systems/coordinate_systems.tex. Code: https://www.labcanvas.com/tikz-library/code/unit-circle-sine-and-cosine.tex
- **Arbelos** (Geometry): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/arbelos/arbelos.tex. Code: https://www.labcanvas.com/tikz-library/code/arbelos.tex
- **Incircle and circumcircle** (Geometry): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/equilateral-triangle-circles/equilateral-triangle-circles.tex. Code: https://www.labcanvas.com/tikz-library/code/incircle-and-circumcircle.tex
- **Koch snowflake** (Geometry): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/koch-snowflake/koch-snowflake.tex. Code: https://www.labcanvas.com/tikz-library/code/koch-snowflake.tex
- **Manhattan distance** (Geometry): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/norms/manhattan_distance.tex. Code: https://www.labcanvas.com/tikz-library/code/manhattan-distance.tex

## Topology

- **Pair of pants** (Topology): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/topology-pair-of-pants/topology-pair-of-pants.tex. Code: https://www.labcanvas.com/tikz-library/code/pair-of-pants.tex

## Graph theory

- **Hamiltonian cycle** (Graph theory): MIT licence, © Petar Veličković. Source: https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Hamiltonian%20graph/hamiltonian_graph.tex. Code: https://www.labcanvas.com/tikz-library/code/hamiltonian-cycle.tex
- **Web graph** (Graph theory): MIT licence, © Petar Veličković. Source: https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Web%20graph/web_graph.tex. Code: https://www.labcanvas.com/tikz-library/code/web-graph.tex
- **Complete bipartite graph K3,3** (Graph theory): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/topology-graph-k-3-3/topology-graph-k-3-3.tex. Code: https://www.labcanvas.com/tikz-library/code/complete-bipartite-graph-k3-3.tex
- **Königsberg bridges** (Graph theory): MIT licence, © Packt (code from LaTeX Graphics with TikZ by Stefan Kottwitz). Source: https://github.com/PacktPublishing/LaTeX-graphics-with-TikZ/blob/82e099639f46ee92bc622a01c739e7f7a3e87f4b/05-using-styles-and-pics/04-konigsberg-bridges.tex. Code: https://www.labcanvas.com/tikz-library/code/konigsberg-bridges.tex

## Functions & calculus

- **Branch cuts in the complex plane** (Functions & calculus): MIT licence, © Janosh Riebesell and contributors. Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/branch-cuts-1/branch-cuts-1.tex. Code: https://www.labcanvas.com/tikz-library/code/branch-cuts-in-the-complex-plane.tex
- **Saddle point surface** (Functions & calculus): MIT licence, © Janosh Riebesell and contributors. Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/saddle-point/saddle-point.tex. Code: https://www.labcanvas.com/tikz-library/code/saddle-point-surface.tex
- **Taylor polynomials of sine** (Functions & calculus): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/taylorpolynom-sin/taylorpolynom-sin.tex. Code: https://www.labcanvas.com/tikz-library/code/taylor-polynomials-of-sine.tex
- **Area under x² (integral)** (Functions & calculus): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/x-2-quadratic-function/x-2-quadratic-function.tex. Code: https://www.labcanvas.com/tikz-library/code/area-under-x2-integral.tex

## Linear algebra & tensors

- **Vector addition and scaling** (Linear algebra & tensors): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/vector-addition-and-scaling/vector-addition-and-scaling.tex. Code: https://www.labcanvas.com/tikz-library/code/vector-addition-and-scaling.tex
- **Highlighting matrix entries** (Linear algebra & tensors): MIT licence, © Packt (code from LaTeX Graphics with TikZ by Stefan Kottwitz). Source: https://github.com/PacktPublishing/LaTeX-graphics-with-TikZ/blob/82e099639f46ee92bc622a01c739e7f7a3e87f4b/09-using-layers/08-highlighting-matrix.tex. Code: https://www.labcanvas.com/tikz-library/code/highlighting-matrix-entries.tex
- **CP tensor factorisation** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/TensorFactorization/CP_factorization.tex. Code: https://www.labcanvas.com/tikz-library/code/cp-tensor-factorisation.tex
- **Third-order tensor** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/TensorFactorization/tensor.tex. Code: https://www.labcanvas.com/tikz-library/code/third-order-tensor.tex
- **Circulant matrix product** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/matrix/linear_circ_mat.tex. Code: https://www.labcanvas.com/tikz-library/code/circulant-matrix-product.tex
- **ℓ1 norm unit ball** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/norms/ell1_norm.tex. Code: https://www.labcanvas.com/tikz-library/code/l1-norm-unit-ball.tex
- **ℓ2 norm unit ball** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/norms/ell2_norm.tex. Code: https://www.labcanvas.com/tikz-library/code/l2-norm-unit-ball.tex
- **Tensor mode-3 product** (Linear algebra & tensors): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/matrix/mode3_prod.tex. Code: https://www.labcanvas.com/tikz-library/code/tensor-mode-3-product.tex

## Probability & statistics

- **Bayes’ theorem, geometrically** (Probability & statistics): MIT licence, © Janosh Riebesell and contributors. Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/geometric-bayes/geometric-bayes.tex. Code: https://www.labcanvas.com/tikz-library/code/bayes-theorem-geometrically.tex
- **Markov chain (rain and sun)** (Probability & statistics): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/markov-chain-rain-sun/markov-chain-rain-sun.tex. Code: https://www.labcanvas.com/tikz-library/code/markov-chain-rain-and-sun.tex
- **Two normal distributions** (Probability & statistics): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/lda-gauss-2/lda-gauss-2.tex. Code: https://www.labcanvas.com/tikz-library/code/two-normal-distributions.tex
- **Normal distribution: rejection regions** (Probability & statistics): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/pgfplots-function/normal_pdf_3.tex. Code: https://www.labcanvas.com/tikz-library/code/normal-distribution-rejection-regions.tex
- **Student’s t vs normal distribution** (Probability & statistics): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/pgfplots-function/student_pdf_1.tex. Code: https://www.labcanvas.com/tikz-library/code/students-t-vs-normal-distribution.tex
- **Log-normal distribution** (Probability & statistics): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/pgfplots-function/lognormal_pdf.tex. Code: https://www.labcanvas.com/tikz-library/code/log-normal-distribution.tex

## Numerical methods

- **Kalman filter** (Numerical methods): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/kalman-filter/kalman-filter.tex. Code: https://www.labcanvas.com/tikz-library/code/kalman-filter.tex
- **Polynomial interpolation (Runge)** (Numerical methods): MIT licence, © Martin Thoma. Source: https://github.com/MartinThoma/LaTeX-examples/blob/f9236c5fe5d47f19822fcb11097df27355562314/tikz/polynomial-interpolation/polynomial-interpolation.tex. Code: https://www.labcanvas.com/tikz-library/code/polynomial-interpolation-runge.tex
- **Conjugate gradient steps** (Numerical methods): MIT licence, © Xinyu Chen. Source: https://github.com/xinychen/awesome-latex-drawing/blob/a11dbbb3796fb279790509fb87e0083f8d11fc96/pgfplots-function/conj_grad_example_2.tex. Code: https://www.labcanvas.com/tikz-library/code/conjugate-gradient-steps.tex
- **Fluid domain with boundary** (Numerical methods): MIT licence, © Ed Bueler. Source: https://github.com/bueler/tikz-examples/blob/5daac3ea54dce86b98454a43c90a1b8ace4fd11d/fluid-domain.tex. Code: https://www.labcanvas.com/tikz-library/code/fluid-domain-with-boundary.tex
- **Q1 finite element basis function** (Numerical methods): MIT licence, © Ed Bueler. Source: https://github.com/bueler/tikz-examples/blob/5daac3ea54dce86b98454a43c90a1b8ace4fd11d/q1hat.tex. Code: https://www.labcanvas.com/tikz-library/code/q1-finite-element-basis-function.tex
- **Five-point stencil on a grid** (Numerical methods): MIT licence, © Ed Bueler. Source: https://github.com/bueler/tikz-examples/blob/5daac3ea54dce86b98454a43c90a1b8ace4fd11d/unitsquaregridstencil.tex. Code: https://www.labcanvas.com/tikz-library/code/five-point-stencil-on-a-grid.tex

## Using these figures

Every figure keeps its own licence: MIT or CC0 1.0, both of which allow use, change and sharing, commercial use included. The MIT licence asks that its copyright and permission notice go with copies of the code, so each figure’s code starts with its source, author and licence; keep those lines when you reuse it. The full licence texts are on the [sources and licences page](https://www.labcanvas.com/tikz-library/credits.html).

“Open in the TikZ editor” loads the figure’s complete document into the free TikZ editor, where it is typeset with TeX Live 2026 and you can change it and download a PNG. To compile it on your own computer, save the code as a.tex file and run pdfLaTeX (or the engine the tile names) on it; LabCanvas changed the files only where needed to make each one compile on its own, as its first lines say.

Licence texts: https://www.labcanvas.com/tikz-library/credits.html
