function calculatePaceHR() {
var age = parseFloat(document.getElementById('calc_age').value);
var restingHR = parseFloat(document.getElementById('calc_resting_hr').value);
var intensity = parseFloat(document.getElementById('calc_intensity').value) / 100;
var distance = parseFloat(document.getElementById('calc_distance').value);
var hours = parseFloat(document.getElementById('calc_hours').value) || 0;
var minutes = parseFloat(document.getElementById('calc_minutes').value) || 0;
var seconds = parseFloat(document.getElementById('calc_seconds').value) || 0;
if (isNaN(age) || isNaN(restingHR) || isNaN(intensity)) {
alert("Please fill in the Age, Resting HR, and Intensity fields.");
return;
}
// Karvonen Formula Logic
var maxHR = 220 – age;
var reserveHR = maxHR – restingHR;
var targetHR = (reserveHR * intensity) + restingHR;
// Pace Logic
var totalSeconds = (hours * 3600) + (minutes * 60) + seconds;
var pacePerKm = 0;
var paceString = "N/A";
var speedKmH = 0;
if (!isNaN(distance) && distance > 0 && totalSeconds > 0) {
pacePerKm = totalSeconds / distance;
var paceMin = Math.floor(pacePerKm / 60);
var paceSec = Math.round(pacePerKm % 60);
paceString = paceMin + ":" + (paceSec < 10 ? "0" + paceSec : paceSec);
speedKmH = (distance / (totalSeconds / 3600)).toFixed(2);
}
// Display results
document.getElementById('res_max_hr').innerText = Math.round(maxHR);
document.getElementById('res_target_hr').innerText = Math.round(targetHR);
document.getElementById('res_pace').innerText = paceString;
document.getElementById('res_speed').innerText = speedKmH;
var zoneText = "";
if (intensity < 0.6) zoneText = "This is a Recovery/Zone 1 effort. Ideal for active recovery and warming up.";
else if (intensity < 0.7) zoneText = "This is an Aerobic/Zone 2 effort. Best for building base endurance and fat burning.";
else if (intensity < 0.8) zoneText = "This is a Tempo/Zone 3 effort. Improves aerobic capacity and efficiency.";
else if (intensity < 0.9) zoneText = "This is a Threshold/Zone 4 effort. Increases anaerobic threshold and speed endurance.";
else zoneText = "This is an Anaerobic/Zone 5 effort. Maximum performance and sprint capacity.";
document.getElementById('hr_zone_info').innerText = zoneText;
document.getElementById('hr_pace_results').style.display = "block";
}
Understanding the Connection Between Pace and Heart Rate
Training effectively requires a balance between your physical output (pace) and your internal physiological response (heart rate). This calculator uses the Karvonen Formula, which is considered more accurate than simple percentages because it accounts for your resting heart rate and heart rate reserve.
What is the Karvonen Formula?
The Karvonen Formula calculates your target heart rate by looking at the difference between your maximum heart rate and your resting heart rate. The formula is:
Efficiency: Learn if you are running too fast for your intended aerobic base building.
Progress Tracking: As you get fitter, you will notice your heart rate stays lower even as your pace increases.
Injury Prevention: Avoid overtraining by ensuring high-intensity days stay in the correct zones and recovery days remain truly easy.
Practical Example
If you are a 35-year-old runner with a resting heart rate of 60 BPM and you want to do a 70% intensity aerobic run for 10km in 55 minutes:
Max HR: 185 BPM
Target HR: Approximately 147 BPM
Target Pace: 5:30 min/km
If your heart rate exceeds 155 BPM during this specific run, you are likely pushing harder than the intended "aerobic" benefit, even if your pace remains 5:30 min/km.