"""Rows 9-17 (12 readings) of Cavendish's table, read by eye from the scan (p. 520): motion of the arm for a full '+ to -' / '- to +' swing (divisions), time of vibration as minutes,seconds, printed density.
A full swing is 2B (his text), so B = motion/2; formula (as in heron/cavendish_formula_check.py): density = 0.985 * T^2 / (10683 * B)."""
rows = [('9', 6.32, (6, 58), 5.10), ('10', 6.15, (6, 59), 5.27), ('11', 6.07, (7, 1), 5.39), ('12', 6.09, (7, 3), 5.42), ('13a', 6.12, (7, 6), 5.47), ('13b', 5.97, (7, 7), 5.63),
        ('14a', 6.27, (7, 6), 5.34), ('14b', 6.13, (7, 6), 5.46), ('15', 6.34, (7, 7), 5.30), ('16', 6.10, (7, 16), 5.75), ('17a', 5.78, (7, 2), 5.68), ('17b', 5.64, (7, 3), 5.85)]
rs = []
for n, mot, (m, s), printed in rows:
    T = 60 * m + s; f = T * T / (10683 * mot / 2); rs.append(printed / f)
    print('%-4s T=%3d s  formula %.3f  printed %.2f  printed/formula %.4f  (0.985*formula = %.2f)' % (n, T, f, printed, printed / f, 0.985 * f))
import statistics as st
print('mean ratio %.4f  sd %.4f  min %.4f max %.4f' % (st.mean(rs), st.stdev(rs), min(rs), max(rs)))
print('max |0.985*formula - printed| = %.3f' % max(abs(0.985 * (r[2][0] * 60 + r[2][1]) ** 2 / (10683 * r[1] / 2) - r[3]) for r in rows))
