The least well-determined physical constants

In this example we will use the scipy.constants.physical_constants dictionary to determine which are the least-accurately known constants. To do this we need the relative uncertainties in the constants' values; the code below uses a structured array to calculate these and outputs the least well-determined constants.

import numpy as np
from scipy.constants import physical_constants

def make_record(k, v):
    """
    Return the record for this constant from the key and value of its entry
    in the physical_constants dictionary.

    """
    name = k
    val, units, abs_unc = v
    # Calculate the relative uncertainty in ppm
    rel_unc = abs_unc / abs(val) * 1.e6
    return name, val, units, abs_unc, rel_unc

dtype = [('name', 'S50'), ('val', 'f8'), ('units', 'S20'),
         ('abs_unc', 'f8'), ('rel_unc', 'f8')]
constants = np.array([make_record(k, v) for k,v in physical_constants.items()],
                     dtype=dtype )
constants.sort(order='rel_unc')

# List the 10 constants with the largest relative uncertainties
for rec in constants[::-1][:10]:
    print('{:.0f} ppm: {:s} = {:g} {:s}'.format(rec['rel_unc'],
              rec['name'].decode(), rec['val'], rec['units'].decode()))

The output is shown below. When this exercise was first written, the Newtonian gravitational constant, $G$, was not known to better than about 120 ppm; newer measurements have put its accuracy at 46 ppm.

9447 ppm: weak mixing angle = 0.2223 
6971 ppm: proton rms charge radius = 8.751e-16 m
1168 ppm: deuteron rms charge radius = 2.1413e-15 m
428 ppm: proton magn. shielding correction = 2.5691e-05 
428 ppm: proton mag. shielding correction = 2.5691e-05 
92 ppm: tau mass = 3.16747e-27 kg
91 ppm: tau mass energy equivalent = 2.84678e-10 J
91 ppm: proton-tau mass ratio = 0.528063 
91 ppm: muon-tau mass ratio = 0.0594649 
91 ppm: neutron-tau mass ratio = 0.52879