How to mathematically describe a spiral torus knot? How would one mathematically describe the geometry as shown? For the purpose of implementing in something like matplotlib.
Spiral Torus Knot
Other examples (easier to see): 

 A: There is a Mathematica Demo Torus Knot, that might help.
The code is freely downloadable, from which you could extract the equations used.
I am not sure, however, that it covers all the knots you want to represent.




Code by Sándor Kabai.


A: I'm not entirely sure what you mean by a "spiral" torus knot, so I'm just going to address your question restricted to ordinary "torus knots". I'll do this on the level of ordinary analytic geometry, giving you formulas which you can plug into the graphical programming environment of your choice.
Let's start with a description of the torus as a surface of rotation in cylindical coordinates $(r,\theta,z)$ as
$$(r-2)^2 + z^2 = 1
$$
This, of course, appears to be a circle in the $r,z$ plane with center $(2,0)$ and radius $1$, but keep in mind that $\theta$ freely varies from $0$ to $2\pi$, and so the circle sweeps out a torus. You can play around with the center and radius, making sure that the circle stays in the half plane $r>0$ which is required for cylindrical coordinates to make sense.
Next, you can convert this into a parametric description of the torus:
$$r = 2 + \cos(s), \quad z = \sin(s), \quad \theta = t, \quad (s,t) \in [0,2\pi] \times [0,2\pi]
$$
Finally, to describe some torus knots, you can let $s$ and $t$ vary as linear functions of a single variable $u$, with slopes being integer multiples of $2\pi$. In other words, for relatively prime integers $m,n \ge 0$ let
$$s = 2 \pi m u, \quad t = 2 \pi n u, \quad u \in [0,1]
$$
Plugging this into the previous equations we have
$$r = 2 + \cos(2 \pi m u), z = \sin(2 \pi m u), \theta = 2 \pi n u, \quad u \in [0,1]
$$
and this sweeps out the $(m,n)$ torus knot in cylindrical coordinates (or maybe its the $(n,m)$ torus knot, its one or the other, and I'm not sure at the moment what the convention is).
You can if you like convert to Euclidean coordinates using
$$x = r \cos(\theta), \quad y = r \sin(\theta)
$$
which gives the parametric equations
$$x = (2 + \cos(2 \pi m u)) \cos(2 \pi n u), \quad y = (2 + \cos(2 \pi m u) \sin (2 \pi n u), \quad z = \sin (2 \pi m u), \quad u \in [0,1]
$$
One other thing you can do to get an animated version is to replace the formulas for $s$ with a formula that depends on an additional time variable $\tau$, something like this:
$$s = 2 \pi m (u+\tau), t = 2 \pi n u
$$
So the formulas as given above are for time $\tau=0$, and as $\tau$ varies from $0$ to $1$ you can keep redrawing the knot to give the animation.
