function calculateGrowthRate() {
// Get input elements using var
var startInput = document.getElementById('startValue');
var endInput = document.getElementById('endValue');
var periodsInput = document.getElementById('numPeriods');
var resultContainer = document.getElementById('resultContainer');
var errorDiv = document.getElementById('errorMessage');
// Parse values
var startVal = parseFloat(startInput.value);
var endVal = parseFloat(endInput.value);
var periods = parseFloat(periodsInput.value);
// Reset display
errorDiv.style.display = 'none';
resultContainer.style.display = 'none';
// Validation logic
if (isNaN(startVal) || isNaN(endVal) || isNaN(periods)) {
errorDiv.innerHTML = "Please enter valid numbers in all fields.";
errorDiv.style.display = 'block';
return;
}
if (periods <= 0) {
errorDiv.innerHTML = "Number of years must be greater than zero.";
errorDiv.style.display = 'block';
return;
}
if (startVal === 0) {
errorDiv.innerHTML = "Beginning value cannot be zero for growth rate calculation.";
errorDiv.style.display = 'block';
return;
}
// Calculation: CAGR = (End / Start)^(1 / n) – 1
var ratio = endVal / startVal;
// Handle negative base with fractional exponent edge case (Math.pow returns NaN for negative base < 1 exponent)
// However, for standard business CAGR, values are usually positive.
// If start is negative and end is positive, CAGR is mathematically complex/undefined in standard finance.
// We will assume standard positive growth metrics or handle simple math.
if (startVal 0) {
errorDiv.innerHTML = "CAGR calculation is not standard when moving from negative to positive equity.";
errorDiv.style.display = 'block';
return;
}
var cagrDecimal = Math.pow(ratio, 1 / periods) – 1;
var cagrPercent = cagrDecimal * 100;
var totalGrowthAbs = endVal – startVal;
var totalGrowthPercent = ((endVal – startVal) / Math.abs(startVal)) * 100;
// Display Results
document.getElementById('absGrowthResult').innerHTML = totalGrowthAbs.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('totalPercentResult').innerHTML = totalGrowthPercent.toFixed(2) + "%";
document.getElementById('cagrResult').innerHTML = cagrPercent.toFixed(2) + "%";
resultContainer.style.display = 'block';
}
How to Calculate the Annual Growth Rate
Understanding how to calculate the annual growth rate—specifically the Compound Annual Growth Rate (CAGR)—is essential for analyzing the performance of investments, business revenue, user bases, or portfolio values over time. Unlike a simple average, the annual growth rate accounts for the compounding effect, providing a smoothed rate of return that describes how a value grew from its beginning balance to its ending balance.
The Annual Growth Rate Formula
To calculate the annual growth rate, you need three specific numbers: the beginning value, the ending value, and the number of periods (usually years) that have passed. The formula assumes that the growth has been steady over the specified duration.
CAGR = ( Ending Value / Beginning Value )1/n – 1
Where:
Ending Value: The current value of the asset or metric.
Beginning Value: The initial value at the start of the period.
n: The number of years or periods involved.
Step-by-Step Calculation Example
Let's look at a realistic business scenario to understand how the math works.
Scenario: A small business had a revenue of 150,000 in Year 1. Five years later (Year 5), the revenue has grown to 280,000.
Identify the Variables:
Beginning Value = 150,000
Ending Value = 280,000
Number of Years (n) = 4 (Note: The gap between Year 1 and Year 5 is 4 years).
Divide End by Start: 280,000 / 150,000 = 1.8667
Raise to the Power of (1/n): 1.8667(1/4) or 1.86670.25 = 1.1689
Subtract 1: 1.1689 – 1 = 0.1689
Convert to Percentage: 0.1689 * 100 = 16.89%
This result means the business revenue grew at an annualized rate of roughly 16.89% per year.
Why Use CAGR Instead of Simple Average?
A simple average growth rate can be misleading because it ignores volatility and the effects of compounding. For example, if an investment drops by 50% one year and grows by 50% the next, you haven't broken even—you are actually down 25%. The Annual Growth Rate formula corrects for this, giving you the true geometric mean return that links the starting and ending values accurately.
Applications of Annual Growth Rate
Investment Portfolios: Comparing the performance of a stock or mutual fund against a benchmark index.
Business Metrics: Tracking revenue, net profit, or customer acquisition costs over multiple quarters or years.
Population Statistics: Analyzing demographic shifts within cities or countries over a decade.