The Mathematics of History