The Annual Percentage Yield (APY) is a normalized representation of an investment's return that takes compounding into account. While the Annual Percentage Rate (APR) states the simple interest you'd earn over a year, APY accounts for the effect of earning interest on your interest. This means that the more frequently your interest is compounded, the higher your APY will be compared to your APR, assuming all other factors remain the same.
How APY is Calculated
The formula used to calculate APY is:
APY = (1 + (r/n))n – 1
Where:
r is the annual nominal interest rate (as a decimal).
n is the number of times the interest is compounded per year.
In our calculator, we first convert the input annual interest rate from a percentage to a decimal by dividing by 100. The calculator then uses this information along with the compounding frequency to determine the APY. The result is then displayed as a percentage.
Why APY Matters
APY is a crucial metric for comparing different savings accounts, certificates of deposit (CDs), or other interest-bearing financial products. Because it reflects the true rate of return due to compounding, it provides a more accurate picture of your potential earnings than the APR alone. When comparing financial products, always look at the APY to make an informed decision about where to best put your money to work for you.
function calculateAPY() {
var principalAmount = parseFloat(document.getElementById("principalAmount").value);
var annualInterestRatePercent = parseFloat(document.getElementById("annualInterestRate").value);
var compoundingFrequency = parseFloat(document.getElementById("compoundingFrequency").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(principalAmount) || isNaN(annualInterestRatePercent) || isNaN(compoundingFrequency) || principalAmount <= 0 || annualInterestRatePercent < 0 || compoundingFrequency <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
var annualInterestRateDecimal = annualInterestRatePercent / 100;
// APY = (1 + (r/n))^n – 1
var apy = Math.pow((1 + (annualInterestRateDecimal / compoundingFrequency)), compoundingFrequency) – 1;
// Format the result to show APY as a percentage with 2 decimal places
var formattedAPY = (apy * 100).toFixed(4);
// Calculate the actual interest earned in a year
var interestEarned = principalAmount * apy;
var formattedInterestEarned = interestEarned.toFixed(2);
resultDiv.innerHTML =
"