# Blog

A blog of Python-related topics and code.

## Visualizing uncertainties in plotted data

The equation for the temperature-dependence of the diffusion of hydrogen in tungsten may be written in Arrhenius form: $$k = A\exp\left(-\frac{E}{T}\right) \quad \Rightarrow \; \ln k = \ln A - \frac{E}{T},$$ where the temperature, $T$, and activation energy, $E$, are expressed in eV and the pre-exponential Arrhenius parameter, $A$, and rate constant, $k$, take units of $\mathrm{m^2\,s^{-1}}$. From the study of Frauenfelder [1] the parameters $A$ and $E$ may be associated with uncertainties as follows: \begin{align*} A & = (4.1 \pm 0.5) \times 10^{-7}\;\mathrm{m^2\,s^{-1}}, \\ E &= 0.39 \pm 0.08 \;\mathrm{eV}. \end{align*} These uncertainties can be propagated to the expression for $\ln k$: $$\sigma_{\ln k} \approx \sqrt{ \left( \frac{\sigma_A}{A} \right)^2 + \left( \frac{\sigma_E}{T} \right)^2 }.$$ If we assume the uncertainty remains normally-distributed, Matplotlib's imshow function can be used to illustrate the Arrhenius equation for this data.

## Turning an image into a sticker chart

To produce a children's sticker chart from a provided image, the following code divides it into squares (which can be cut out) and produces further images with matching labels for the reverse side of the printed image and a piece of card onto which the squares can be stuck (you need to provide your own glue).

## The distribution of Easter dates

Loosely speaking, in the Gregorian calendar, Easter falls on the first Sunday following the first full Moon on or after 21 March. There are various algorithms (Computus) which can be used to calculate its date, and the cycle of dates repeats every 5.7 million years. The following code produces a bar chart of the distribution of Easter dates using one of these algorithms.

## Linear transformations on the two-dimensional plane

A linear transformation in two dimensions can be visualized through its effect on the two orthonormal basis vectors $\hat{\imath}$ and $\hat{\jmath}$. In general, it can be represented by a $2 \times 2$ matrix, $\boldsymbol{T}$, which acts on a vector $v$ to map it from a vector space spanned by one basis onto a different vector space spanned by another basis: $\boldsymbol{v'} = \boldsymbol{T}\boldsymbol{v}$. This change of basis can be visualized by drawing the basis vectors in the two-dimensional plane, along with equally-spaced "grid lines" parallel to each of them. A linear transformation keeps the grid lines evenly spaced, and the origin fixed.

## What N Things?

The mildly controversial geocoding system What3words encodes the geographic coordinates of a location (to a resolution of 3 m) on the Earth's surface into three dictionary words, through some proprietary algorithm. The idea is that human's find it easier to remember and communicate these words than the sequence of digits that makes up the corresponding latitude and longitude. For example, the Victoria Memorial in front of Buckingham Palace in London is located at (51.50187, -0.14063) in decimal latitude, longitude coordinates, but simply using.woods.laws in the language of What3words.