HomeArticlesMedicine & Biophysics

Mathematical ECG and Heart Models

How a nonlinear oscillator explains the heartbeat — from SA node automatism to the Van der Pol equation, the McSharry model of the PQRST wave, and the dynamics behind arrhythmia.

mysimulator teamUpdated July 2026≈ 9 min read▶ Open the simulation

The heart is a network of coupled oscillators

Unlike skeletal muscle, cardiac muscle is autorhythmic: specialised cells in the sinoatrial (SA) node spontaneously generate action potentials at a natural rate of 60–100 beats per minute in a resting adult. The signal propagates through the atria, converges at the atrioventricular (AV) node — where it is deliberately delayed by roughly 120 ms so the ventricles have time to fill — then races through the His-Purkinje system to activate both ventricles almost simultaneously. If the SA node fails, the AV node can take over at 40–60 bpm, and if that fails too, ventricular cells will pace at 20–40 bpm: a hierarchy of backup pacemakers. The electrocardiogram (ECG) records the heart's net electrical dipole from the skin, with the P wave marking atrial depolarisation, the QRS complex marking ventricular depolarisation, and the T wave marking ventricular repolarisation.

The Van der Pol oscillator

Balthasar van der Pol introduced his oscillator in 1926 to describe oscillations in vacuum-tube circuits, and used it to model the heartbeat himself as early as 1928. It has become a canonical model of biological oscillators:

d²x/dt² − μ(1 − x²)dx/dt + x = 0
as a 2D system:  dx/dt = y,  dy/dt = μ(1 − x²)y − x
μ > 0 controls the strength of the nonlinear damping

For |x| < 1 the damping term is negative — it injects energy and amplifies small oscillations; for |x| > 1 it is positive and dissipates energy, limiting large ones. The result is a stable limit cycle that every initial condition converges to. For large μ, the trajectory develops a fast-slow character — a relaxation oscillation — that closely resembles the shape of a cardiac action potential: slow diastolic depolarisation, a rapid spike, a slow plateau, then rapid repolarisation.

live demo · a self-sustained relaxation oscillation● LIVE

The McSharry dynamical ECG model

McSharry et al. (2003, IEEE Transactions on Biomedical Engineering) built an influential model that generates realistic ECG waveforms from a three-dimensional system of ODEs: a trajectory circles the unit circle in (x, y), and Gaussian-shaped deflections are added to the z-coordinate to build the PQRST morphology.

dx/dt = α·x − ω·y      α = 1 − √(x²+y²)  (keeps trajectory on the unit circle)
dy/dt = α·y + ω·x      ω = 2πf             (angular frequency of heart rate f)
dz/dt = −Σᵢ aᵢ·Δθᵢ·exp(−Δθᵢ²/2bᵢ²) − (z − z₀)   Δθᵢ = (θ − θᵢ) mod 2π

Event   θᵢ (rad)   aᵢ      bᵢ
P       −π/3       1.2     0.25
Q       −π/12      −5.0    0.10
R       0          30.0    0.10
S       π/12       −7.5    0.10
T       π/2        0.75    0.40

As the phase θ = atan2(y, x) sweeps around the circle, it encounters each of the five Gaussians (P, Q, R, S, T) in sequence, producing the characteristic PQRST waveform in z(t).

Reading the QRS complex

The QRS complex is the dominant feature of the ECG: a sharp, narrow (80–120 ms) deflection from ventricular depolarisation. The Q wave is a small initial negative deflection from septal depolarisation moving away from left-sided leads; the R wave is the large positive peak from the main left-ventricular depolarisation wave moving toward those leads; the S wave is the terminal negative deflection from basal depolarisation moving superiorly and rightward. Around it, the PR interval (120–200 ms) reflects AV conduction delay, the ST segment is isoelectric while all ventricular cells are depolarised (its elevation can indicate ischaemia or infarction), and the QT interval represents total ventricular electrical systole — prolongation beyond a corrected QTc of 440 ms risks the arrhythmia torsades de pointes.

When the rhythm breaks: arrhythmia mechanisms

Arrhythmias arise from disturbances in impulse generation, conduction, or both. Enhanced automaticity occurs when non-pacemaker cells spontaneously depolarise, competing with the SA node to produce premature beats. Triggered activity comes from afterdepolarisations reaching threshold — early afterdepolarisations during the plateau phase can trigger torsades de pointes, while delayed afterdepolarisations in phase 4 are driven by calcium overload. The most common mechanism behind sustained tachyarrhythmias, including atrial fibrillation and ventricular tachycardia, is re-entry: an anatomical or functional circuit with unidirectional block in one limb and conduction slow enough for the blocked tissue to recover. Mathematically this is a rotating spiral wave; when its tip meets a singularity it can break into multiple wavelets — the proposed onset of fibrillation, and the target of catheter-ablation therapy aimed at the rotor cores that sustain it.

Frequently asked questions

What is the Van der Pol oscillator and why does it model the heartbeat?

The Van der Pol oscillator, introduced in 1926 to describe vacuum-tube circuits, has a nonlinear damping term that injects energy into small oscillations and removes energy from large ones, producing a stable limit cycle. For large damping strength μ it develops a fast-slow relaxation-oscillation shape — slow rise, rapid spike, slow plateau, rapid fall — that mirrors a cardiac action potential, which is why Van der Pol himself used it to model the heartbeat as early as 1928.

What causes the QRS complex on an ECG?

The QRS complex is a sharp, narrow (80–120 ms) deflection caused by ventricular depolarisation. The Q wave is septal depolarisation moving away from left-sided leads, the R wave is the main left-ventricular depolarisation wave moving toward those leads, and the S wave is terminal basal depolarisation moving superiorly and rightward. Its large amplitude reflects the simultaneous activation of the thick ventricular wall.

What is re-entry and how does it cause arrhythmias?

Re-entry is the most common mechanism behind sustained tachyarrhythmias such as atrial fibrillation and ventricular tachycardia. It requires an anatomical or functional circuit, unidirectional block in one limb, and conduction slow enough for the blocked tissue to recover. Mathematically it is a rotating spiral wave; when its tip meets a singularity it can break into multiple wavelets, which is thought to underlie fibrillation.

Try it live

Everything above runs in your browser — open Mathematical ECG and Heart Models and watch a synthetic PQRST trace unfold in real time, with sliders for heart rate, QRS amplitude, PR interval and an arrhythmia toggle. Nothing is installed, nothing is uploaded.

▶ Open the ECG & Heart Model simulation

What did you find?

Add reproduction steps (optional)