« home

Bloch Sphere

physicsquantum mechanicscetztikz

A Bloch sphere of radius |a| = 1 contains all possible states of a two-state quantum system (qubit). Each Bloch vector fully determines a spin-1/2 density matrix. Used in Exercise Sheet 10 of Statistical Physics by Manfred Salmhofer (2016), available at https://janosh.dev/physics/statistical-physics.


Bloch Sphere

  Download

PNGPDFSVG

  Code

  LaTeX

bloch-sphere.tex (30 lines)

\documentclass[tikz]{standalone}

\usetikzlibrary{angles, quotes}

\begin{document}
\begin{tikzpicture}

  % Define radius
  \def\r{3}

  % Bloch vector
  \draw (0, 0) node[circle, fill, inner sep=1] (orig) {} -- (\r/3, \r/2) node[circle, fill, inner sep=0.7, label=above:$\vec{a}$] (a) {};
  \draw[dashed] (orig) -- (\r/3, -\r/5) node (phi) {} -- (a);

  % Sphere
  \draw (orig) circle (\r);
  \draw[dashed] (orig) ellipse (\r{} and \r/3);

  % Axes
  \draw[->] (orig) -- ++(-\r/5, -\r/3) node[below] (x1) {$x_1$};
  \draw[->] (orig) -- ++(\r, 0) node[right] (x2) {$x_2$};
  \draw[->] (orig) -- ++(0, \r) node[above] (x3) {$x_3$};

  % Angles
  \pic [draw=gray, text=gray, ->, "$\phi$"] {angle = x1--orig--phi};
  \pic [draw=gray, text=gray, <-, "$\theta$", angle eccentricity=1.4] {angle = a--orig--x3};

\end{tikzpicture}
\end{document}

  Typst

bloch-sphere.typ (55 lines)

#import "@preview/cetz:0.3.2"

#set page(width: auto, height: auto, margin: 8pt)

#cetz.canvas({
  // Helper coordinates
  let rad = 2.5
  let vec-a = (rad / 3, rad / 2)
  let phi-point = (rad / 3, -rad / 5)

  // Bloch vector
  cetz.draw.line((0, 0), vec-a)
  cetz.draw.circle((0, 0), radius: 1pt, fill: black)
  cetz.draw.circle(vec-a, radius: 1pt, fill: black)
  // content(vec-a + (0.1, 0.2), [$vec(a)$])

  // Dashed line forming angle
  cetz.draw.line((0, 0), phi-point, style: "dashed")
  cetz.draw.line(phi-point, vec-a, style: "dashed")
  // Axes
  let arrow-extend = 1.15
  cetz.draw.line((0, 0), (-rad / 5, -rad / 3), mark: (end: "stealth", fill: black))
  cetz.draw.content((-rad / 5 - 0.2, -rad / 3 - 0.2), [$x_1$])

  cetz.draw.line((0, 0), (arrow-extend * rad, 0), mark: (end: "stealth", fill: black))
  cetz.draw.content((arrow-extend * rad + 0.2, 0), [$x_2$])

  cetz.draw.line((0, 0), (0, arrow-extend * rad), mark: (end: "stealth", fill: black))
  cetz.draw.content((0, arrow-extend * rad + 0.2), [$x_3$])

  // Angles
  cetz.angle.angle(
    (0, 0),
    (-1, -calc.tan(60deg)),
    (1, -calc.tan(30deg)),
    label: [$phi$],
    stroke: (paint: gray, thickness: .5pt),
    mark: (end: "stealth", fill: gray, scale: .7),
  )

  cetz.angle.angle(
    (0, 0),
    (1, calc.tan(60deg)),
    (1, calc.tan(90deg)),
    label: [$theta$],
    stroke: (paint: gray, thickness: .5pt),
    mark: (start: "stealth", fill: gray, scale: .7),
    label-radius: 0.75,
  )

  // Sphere
  cetz.draw.circle((0, 0), radius: rad)
  cetz.draw.circle((0, 0), radius: (rad, rad / 3), stroke: (dash: "dashed"), fill: gray.transparentize(70%))
})