Compound Annual Growth Rate (CAGR) Calculator
What is Compound Annual Growth Rate (CAGR)?
The Compound Annual Growth Rate (CAGR) is a measure of the average annual growth of an investment over a specified period of time, greater than one year. It is often used to represent the growth of a company's revenue, a portfolio's value, or any other metric that compounds over time. CAGR smooths out volatility and provides a single, representative rate of growth.
The formula for CAGR is:
CAGR = ( (Ending Value / Starting Value) ^ (1 / Number of Years) ) – 1
Where:
- Starting Value: The initial value of the investment or metric.
- Ending Value: The final value of the investment or metric.
- Number of Years: The total number of years over which the growth occurred.
CAGR is a valuable tool for investors and analysts because it provides a standardized way to compare the growth rates of different investments or to assess the historical performance of a single investment. It's important to remember that CAGR is a hypothetical smoothed rate and doesn't reflect the actual year-to-year fluctuations in value.
Example:
Let's say you invested $10,000 in a stock portfolio at the beginning of 2018. By the end of 2022 (5 years later), your portfolio is worth $25,000. To calculate the CAGR:
- Starting Value = $10,000
- Ending Value = $25,000
- Number of Years = 5
Using the formula:
CAGR = ( ($25,000 / $10,000) ^ (1 / 5) ) – 1
CAGR = ( 2.5 ^ 0.2 ) – 1
CAGR = 1.2011 – 1
CAGR = 0.2011 or 20.11%
This means your portfolio grew at an average annual rate of 20.11% over those 5 years.
function calculateCAGR() {
var startValue = parseFloat(document.getElementById("startValue").value);
var endValue = parseFloat(document.getElementById("endValue").value);
var years = parseFloat(document.getElementById("years").value);
var resultElement = document.getElementById("result");
if (isNaN(startValue) || isNaN(endValue) || isNaN(years) || startValue <= 0 || endValue < 0 || years <= 0) {
resultElement.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
var cagr = Math.pow((endValue / startValue), (1 / years)) – 1;
var formattedCAGR = (cagr * 100).toFixed(2) + "%";
resultElement.innerHTML = "The Compound Annual Growth Rate (CAGR) is:
" + formattedCAGR + "";
}
.calculator-container {
font-family: sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-bottom: 30px;
padding: 20px;
background-color: #f9f9f9;
border-radius: 5px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
.input-group input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
.calculator-inputs button {
grid-column: 1 / -1; /* Span across all columns */
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-inputs button:hover {
background-color: #0056b3;
}
.calculator-results {
margin-top: 30px;
padding: 20px;
background-color: #e7f3ff;
border-radius: 5px;
text-align: center;
}
.calculator-results h3 {
color: #007bff;
margin-bottom: 15px;
}
.calculator-results p {
font-size: 18px;
color: #333;
}
.calculator-results strong {
color: #d9534f;
}
.calculator-explanation {
margin-top: 40px;
border-top: 1px solid #eee;
padding-top: 30px;
}
.calculator-explanation h3 {
color: #333;
margin-bottom: 15px;
}
.calculator-explanation p, .calculator-explanation ul {
color: #666;
line-height: 1.6;
}
.calculator-explanation ul {
margin-left: 20px;
margin-top: 10px;
}
.calculator-explanation li {
margin-bottom: 8px;
}
.calculator-explanation strong {
color: #333;
}