A blog of Python-related topics and code.

Least-squares fitting to an exponential function

Many phenomena can be described in terms of a measured variable varying exponentially with a quantity. For example, a processes such as radioactive decay and first-order reaction rates are described by an ordinary differential equation of the form

An Arepo (Latin Wordle) Solver

Arepo is a word-guessing game like Wordle, but in Latin. Therefore, the Wordle-solving script presented previously can be used to solve Arepo problems, but a list of five-letter Latin words is required.

A Python Wordle Solver

Wordle is a daily online word-guessing game. The goal is to deduce the hidden five-letter word in as few guesses as possible: after each guess, the player is told which letters which match in the correct position (highlighted in green), which letters are present in the hidden word, but in a different position (highlighted in yellow) and which letters are not present (after those highlighted in green or yellow; these letters are presented on a grey background).

COVID deaths and vacciantion rates

The Python script below generates the following visualization of COVID deaths per 100,000 people for two classes of European country: those with less than 75% of the population vaccinated and those with at least this percentage vaccinated. The ongoing (as of January 2022) third wave of infections is causing fewer deaths in the countries with a higher vaccination rate.

The Klein–Nishina formula

The Klein–Nishina formula gives the differential cross section for the scattering of photons off an electron. At low energies, light scatters elastically (Thomson scattering); at higher energies (for example, gamma radiation), inelastic Compton scattering occurs. In terms of the incoming and outgoing photon wavelengths, $\lambda$ and $\lambda'$: