A blog of Python-related topics and code.

The Hamiltonian of a simple pendulum of mass $m$ and length $l$ may be written $$ \textstyle H = T + V = \frac{1}{2}ml^2\dot{\theta}^2 + mgl(1-\cos\theta) $$ Or, dividing by the moment of inertia, $I=ml^2$, $$ \textstyle H' = \frac{1}{2}\dot{\theta}^2 + \frac{g}{l}(1-\cos\theta) $$ Contours of constant $H$ in the phase space $(\theta, \dot{\theta})$ are plotted below, with the contour corresponding to the separatrix highlighted. This is the value of $H=2g/l$ corresponding to the boundary between two distinct kinds of motion: for $H$ less than this value, the pendulum swings back and forth (closed curves in phase space); for $H$ greater than this, the pendulum turns in continuous circles.

Viviani's curve is the line of intersection between a sphere of radius $2a$ and a cylinder of radius $a$ which is tangent to the sphere and also passes through its centre.

A binary regular solution is one in which the two components, A and B, mix with an entropy of mixing given by the ideal solution model,
$$
\Delta_\mathrm{mix}S = -R(x_1\ln x_1 + x_2\ln x_2)
$$
but have a non-zero enthalpy of mixing given by the relation
$$
\Delta_\mathrm{mix}H = \beta x_1 x_2
$$
where $\beta$ is a parameter describing the difference between the A–B interaction and the average of the A–A and B–B interactions. If $\beta > 0$, there may be some compositions which are immiscible at some temperatures. In this case, it can be shown that there is a maximum temperature, the *upper critical solution temperature* (UCST), given by $T_\mathrm{c} = \frac{\beta}{2R}$, above which all compositions are miscible.

The Ulam Spiral is a simple way to visualize the prime numbers which reveals unexpected, irregular structure. Starting at the centre of a rectangular grid of numbers and spiralling outwards, mark the primes as `1`

and the composite numbers as `0`

.