Mathematical analysis of cardiac rhythm