====== Post 4 — Homotopies Between Loops ======
This entry introduces homotopies as continuous deformations between loops on the Bloch sphere, with examples using the [[https://github.com/erikkallman/hottbloch|accompanying Python code]].
----
===== 1. Homotopy concept =====
A **homotopy** is a continuous deformation from one loop $\gamma_0$ to another loop $\gamma_1$.
Formally, it is a function
\[ H : [0,1] \times [0,1] \to S^2, \]
such that
\[ H(0,t) = \gamma_0(t), \quad H(1,t) = \gamma_1(t). \]
On the Bloch sphere, this means smoothly sliding one path into another without cutting or breaking it.
Because $\pi_1(S^2) = 0$, all loops are contractible: they can be deformed to a point.
----
===== 2. Geodesic interpolation =====
We implement homotopies numerically by interpolating each pair of points on two loops with the shortest geodesic on the sphere.
For points $p,q \in S^2$, the interpolated point at fraction $s$ is
\[ \gamma_s = \frac{\sin((1-s)\theta)}{\sin \theta} \, p + \frac{\sin(s\theta)}{\sin \theta} \, q, \]
where $\theta = \arccos(p \cdot q)$.
----
===== 3. Using the code =====
The function **homotopy_between_loops** constructs these intermediate loops.
Example: deforming the meridian loop into the equatorial loop.
import numpy as np
import hottbloch as h
# Get canonical loops
states_a, loop_a = h.loop_meridian()
states_b, loop_b = h.loop_equator()
# Build homotopy (5 intermediate slices)
s_values = np.linspace(0, 1, 5)
slices = h.homotopy_between_loops(loop_a, loop_b, s_values)
print("Number of slices:", len(slices))
print("Shape of one slice:", slices[0].shape)
Output: five slices, each a discretized loop with shape `(401, 3)`.
----
===== 4. Visualization =====
To generate homotopy plots:
python hottbloch.py --out ./hott_outputs --loop equator --theta 6.283185 --slices 5
This produces a series of images in `./hott_outputs`, each showing a loop at a different interpolation value $s$.
----
===== Conclusion =====
Homotopies reveal that all loops on the Bloch sphere can be continuously deformed into one another, reflecting the trivial fundamental group of $S^2$.
In the next post we extend this picture by considering the **Hopf fibration** and the role of global phase.