Compound Annual Growth Rate (CAGR) Calculator
What is 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 growth rate. CAGR is often used to compare the historical performance of different investments.
How to Calculate CAGR:
The formula for CAGR is as follows:
CAGR = ( (Ending Value / Beginning Value) ^ (1 / Number of Years) ) – 1
Where:
- Ending Value: The value of the investment at the end of the period.
- Beginning Value: The value of the investment at the beginning of the period.
- Number of Years: The total number of years in the investment period.
Why is CAGR Important?
CAGR is a valuable tool for investors because it provides a standardized way to measure and compare investment performance. It helps to:
- Assess historical performance: Understand how an investment has grown over time.
- Compare investments: Easily compare the growth rates of different assets or portfolios.
- Set realistic expectations: Gauge potential future growth based on historical trends.
- Smooth out volatility: Provide a clearer picture of growth by averaging out fluctuations.
Example Calculation:
Let's say you invested $10,000 in a stock (Beginning Value). After 5 years (Number of Years), your investment has grown to $25,000 (Ending Value).
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 approximately 20.11% over the 5-year period.
.calculator-container {
font-family: sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
padding: 15px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
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: span 1; /* Adjust span for button placement if needed */
align-self: center; /* Center button vertically */
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
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: #e9ecef;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 18px;
font-weight: bold;
text-align: center;
color: #28a745;
}
.calculator-explanation {
margin-top: 30px;
padding: 20px;
background-color: #fff;
border: 1px solid #eee;
border-radius: 5px;
}
.calculator-explanation h3, .calculator-explanation h4 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation p {
line-height: 1.6;
color: #666;
margin-bottom: 10px;
}
.calculator-explanation ul {
list-style-type: disc;
margin-left: 20px;
color: #666;
}
.calculator-explanation li {
margin-bottom: 5px;
}
@media (max-width: 600px) {
.calculator-inputs {
grid-template-columns: 1fr;
}
.calculator-inputs button {
grid-column: span 1;
width: 100%;
}
}
function calculateCAGR() {
var beginningValue = parseFloat(document.getElementById("beginningValue").value);
var endingValue = parseFloat(document.getElementById("endingValue").value);
var numberOfYears = parseFloat(document.getElementById("numberOfYears").value);
var resultElement = document.getElementById("result");
resultElement.style.color = "#28a745"; // Default to green for success
if (isNaN(beginningValue) || isNaN(endingValue) || isNaN(numberOfYears)) {
resultElement.textContent = "Please enter valid numbers for all fields.";
resultElement.style.color = "#dc3545"; // Red for error
return;
}
if (beginningValue <= 0) {
resultElement.textContent = "Beginning value must be greater than zero.";
resultElement.style.color = "#dc3545";
return;
}
if (endingValue < 0) {
resultElement.textContent = "Ending value cannot be negative.";
resultElement.style.color = "#dc3545";
return;
}
if (numberOfYears <= 0) {
resultElement.textContent = "Number of years must be greater than zero.";
resultElement.style.color = "#dc3545";
return;
}
var cagr = (Math.pow((endingValue / beginningValue), (1 / numberOfYears))) – 1;
// Display CAGR as a percentage, rounded to 2 decimal places
resultElement.textContent = "CAGR: " + (cagr * 100).toFixed(2) + "%";
}