Compound Annual Growth Rate (CAGR) Calculator
Understanding Compound Annual Growth Rate (CAGR)
The Compound Annual Growth Rate (CAGR) is a financial metric that measures the mean annual growth rate of an investment over a specified period of time longer than one year. It smooths out the volatility of returns to give you a representative annual growth figure. CAGR is useful for comparing the performance of different investments over time, as it accounts for the effects of compounding.
Essentially, CAGR tells you what constant rate of return would have been required for your investment to grow from its beginning value to its ending value over the given number of years, assuming that profits were reinvested at the end of each year.
How CAGR is Calculated:
The formula for CAGR is:
CAGR = [(Ending Value / Beginning Value)^(1 / Number of Years)] – 1
To calculate CAGR, you need three key pieces of information:
- Beginning Investment Value: The initial amount invested.
- Ending Investment Value: The final value of the investment after the specified period.
- Number of Years: The duration over which the investment grew.
Example:
Let's say you invested $10,000 in a stock portfolio at the beginning of 2019. By the end of 2023 (a period of 5 years), your portfolio is worth $25,000.
- Beginning Value = $10,000
- Ending Value = $25,000
- Number of Years = 5
Using the CAGR 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 investment grew at an average annual rate of 20.11% over the 5-year period.
Note: CAGR is a theoretical rate and does not reflect actual year-to-year performance, which can be much more volatile.
function calculateCAGR() {
var beginningValue = parseFloat(document.getElementById("beginningValue").value);
var endingValue = parseFloat(document.getElementById("endingValue").value);
var years = parseFloat(document.getElementById("years").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(beginningValue) || isNaN(endingValue) || isNaN(years)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (beginningValue <= 0) {
resultDiv.innerHTML = "Beginning Investment Value must be greater than zero.";
return;
}
if (endingValue < 0) {
resultDiv.innerHTML = "Ending Investment Value cannot be negative.";
return;
}
if (years <= 0) {
resultDiv.innerHTML = "Number of Years must be greater than zero.";
return;
}
var cagr = Math.pow((endingValue / beginningValue), (1 / years)) – 1;
// Format the result as a percentage
var formattedCAGR = (cagr * 100).toFixed(2) + "%";
resultDiv.innerHTML = "
Your Compound Annual Growth Rate (CAGR) is:
" + formattedCAGR + "";
}
.calculator-container {
font-family: Arial, sans-serif;
max-width: 700px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 25px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 25px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box; /* Ensure padding doesn't affect width */
}
.calculator-inputs button {
grid-column: 1 / -1; /* Span across all columns if in a grid */
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-result {
margin-top: 20px;
padding: 15px;
background-color: #e7f3ff;
border: 1px solid #b3d7ff;
border-radius: 4px;
text-align: center;
}
.calculator-result h3 {
color: #0056b3;
margin-bottom: 10px;
}
.calculator-result p {
font-size: 18px;
font-weight: bold;
color: #333;
}
.calculator-explanation {
margin-top: 30px;
border-top: 1px solid #eee;
padding-top: 20px;
font-size: 14px;
line-height: 1.6;
color: #666;
}
.calculator-explanation h3,
.calculator-explanation h4 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation p {
margin-bottom: 15px;
}
.calculator-explanation ul {
margin-left: 20px;
margin-bottom: 15px;
}
.calculator-explanation strong {
color: #000;
}