A Certificate of Deposit (CD) is a savings product offered by banks and credit unions that allows you to earn a fixed interest rate over a specific period of time. CD terms can range from a few months to several years. In exchange for keeping your money locked up for the term, banks typically offer higher interest rates than standard savings accounts.
How the CD Yield Calculator Works
This calculator helps you estimate the total value of your investment and the interest you'll earn at the end of your CD term. It uses the compound interest formula, which accounts for interest earning interest over time. The formula for compound interest is:
A = P (1 + r/n)^(nt)
Where:
A = the future value of the investment/loan, including interest
P = the principal investment amount (the initial deposit)
r = the annual interest rate (as a decimal)
n = the number of times that interest is compounded per year
t = the number of years the money is invested or borrowed for
Breakdown of Inputs:
Principal Amount: This is the initial sum of money you deposit into the CD.
Annual Interest Rate: This is the yearly rate of return offered by the CD, expressed as a percentage.
Term (in months): This is the duration of the CD. The calculator converts this to years for the formula.
Compounding Frequency: This specifies how often the interest is calculated and added to the principal. Common frequencies include annually (once a year), semi-annually (twice a year), quarterly (four times a year), and monthly (twelve times a year). The calculator will interpret common terms like "annually", "semi-annually", "quarterly", and "monthly". If an unrecognized term is entered, it defaults to annual compounding.
How the Calculator Calculates:
It converts the Annual Interest Rate from a percentage to a decimal (e.g., 4.5% becomes 0.045).
It determines the number of compounding periods per year (n) based on the Compounding Frequency input. For example:
Annually: n = 1
Semi-annually: n = 2
Quarterly: n = 4
Monthly: n = 12
Any other input defaults to n = 1 (annually).
It converts the Term (in months) into years by dividing by 12 (t = termInMonths / 12).
It plugs these values into the compound interest formula to calculate the Total Value at Maturity (A).
It then calculates the Total Interest Earned by subtracting the original Principal Amount from the Total Value at Maturity (Total Interest = A - P).
Example Scenario:
Let's say you invest $10,000 in a CD with a 4.5% annual interest rate for 24 months, compounded monthly.
Principal (P): $10,000
Annual Interest Rate (r): 4.5% or 0.045
Term (t): 24 months / 12 months/year = 2 years
Compounding Frequency (n): Monthly = 12
Using the formula: A = 10000 * (1 + 0.045/12)^(12*2)
A = 10000 * (1 + 0.00375)^24
A = 10000 * (1.00375)^24
A ≈ 10000 * 1.0938069
A ≈ $10,938.07
Total Interest Earned = $10,938.07 – $10,000 = $938.07
This calculator automates this calculation for you, providing a quick estimate of your CD's potential return.
function calculateCDYield() {
var principalAmount = parseFloat(document.getElementById("principalAmount").value);
var annualInterestRate = parseFloat(document.getElementById("annualInterestRate").value);
var termInMonths = parseFloat(document.getElementById("termInMonths").value);
var compoundingFrequencyInput = document.getElementById("compoundingFrequency").value.toLowerCase();
var totalValueElement = document.getElementById("totalValue");
var totalInterestElement = document.getElementById("totalInterest");
// Clear previous results
totalValueElement.textContent = "–";
totalInterestElement.textContent = "–";
// Validate inputs
if (isNaN(principalAmount) || isNaN(annualInterestRate) || isNaN(termInMonths) || principalAmount <= 0 || annualInterestRate < 0 || termInMonths <= 0) {
alert("Please enter valid positive numbers for all fields.");
return;
}
// Determine compounding frequency multiplier (n)
var n = 1; // Default to annually
if (compoundingFrequencyInput.includes("annually")) {
n = 1;
} else if (compoundingFrequencyInput.includes("semi-annually") || compoundingFrequencyInput.includes("semiannually")) {
n = 2;
} else if (compoundingFrequencyInput.includes("quarterly") || compoundingFrequencyInput.includes("quarter")) {
n = 4;
} else if (compoundingFrequencyInput.includes("monthly") || compoundingFrequencyInput.includes("month")) {
n = 12;
} else if (compoundingFrequencyInput.includes("daily")) {
n = 365;
} else {
// If input is not recognized, it's best to inform or default.
// Defaulting to annual compounding for simplicity if input is unclear.
console.warn("Unrecognized compounding frequency. Defaulting to annual compounding.");
n = 1;
}
// Convert annual rate to decimal
var r = annualInterestRate / 100;
// Convert term from months to years
var t = termInMonths / 12;
// Calculate total value using compound interest formula: A = P (1 + r/n)^(nt)
var totalValue = principalAmount * Math.pow((1 + r / n), (n * t));
// Calculate total interest earned
var totalInterest = totalValue – principalAmount;
// Display results, formatted to two decimal places
totalValueElement.textContent = "$" + totalValue.toFixed(2);
totalInterestElement.textContent = "$" + totalInterest.toFixed(2);
}