Calculate the periodic payment for an annuity using this tool, mimicking Excel's PMT function.
Your Calculated Periodic Payment:
—
Understanding the PMT Function in Finance and Excel
The PMT function is a fundamental tool in financial mathematics, widely used in spreadsheets like Microsoft Excel and Google Sheets to calculate the payment made each period for a loan or an investment based on constant payments and a constant interest rate. It's crucial for understanding loan amortization, savings plans, and other annuity calculations.
The Mathematical Formula Behind PMT
The PMT function calculates the payment for a loan or annuity using the following formula:
PMT(rate, nper, pv, [fv], [type])
Where:
rate: The interest rate per period for the loan or annuity. This must be expressed as a decimal. For example, an annual interest rate of 5% compounded monthly would have a rate of 0.05 / 12.
nper: The total number of payment periods for the loan or annuity. This should correspond to the rate (e.g., if rate is monthly, nper should be the total number of months).
pv: The present value, or the lump-sum amount that a series of future payments is worth right now. For loans, this is typically the principal amount borrowed. It's conventionally represented as a negative number (outflow), though the function will return a positive payment if PV is positive.
fv (Optional): The future value, or a cash balance you want to attain after the last payment is made. If omitted, it is assumed to be 0 (e.g., for a loan where the balance is paid off). This is typically entered as 0 or a negative number representing the target balance.
type (Optional): The number 0 or 1 that indicates when payments are due.
0 or omitted: Payments are due at the end of the period (ordinary annuity).
1: Payments are due at the beginning of the period (annuity due).
How the Calculation Works
The core logic implemented in this calculator directly mirrors the mathematical formula Excel uses. For an ordinary annuity (type = 0):
Our JavaScript function combines these, taking into account the type parameter to adjust the calculation accordingly. Note that if the rate is 0, a different formula is used to avoid division by zero.
Use Cases for the PMT Calculator
Loan Amortization: Determine the fixed monthly payment for a mortgage, auto loan, or personal loan. Input the loan amount as PV, the annual interest rate divided by 12 as the rate, and the loan term in months as NPER.
Savings Goals: Calculate how much you need to save periodically to reach a specific future financial goal (e.g., retirement fund, down payment for a house). Here, PV would be 0 (or negative if you're starting with debt), FV would be your savings target, and rate/NPER would reflect your investment growth assumptions.
Leasing Calculations: Understand the periodic cost of leasing a vehicle or equipment.
Annuity Planning: Calculate regular contributions needed for an annuity investment.
Important Considerations
Units Consistency: Ensure that the rate (per period) and nper (number of periods) are consistent. If you have an annual rate, divide it by the number of periods per year (e.g., 12 for monthly).
Sign Convention: The PMT function typically returns a negative number because payments are cash outflows. In our calculator, we present the absolute value for clarity, indicating the amount you pay or save per period. Inputting PV as a negative number (loan amount) and FV as 0 is standard for loan calculations.
Zero Interest Rate: If the interest rate is zero, the PMT calculation simplifies to -(pv + fv) / nper. This calculator handles this edge case.
function calculatePmt() {
var rateInput = document.getElementById("rate");
var nperInput = document.getElementById("nper");
var pvInput = document.getElementById("pv");
var fvInput = document.getElementById("fv");
var typeInput = document.getElementById("type");
var resultValueDiv = document.getElementById("result-value");
var rate = parseFloat(rateInput.value);
var nper = parseInt(nperInput.value);
var pv = parseFloat(pvInput.value);
var fv = parseFloat(fvInput.value);
var type = parseInt(typeInput.value);
// Input validation
if (isNaN(rate) || isNaN(nper) || isNaN(pv) || isNaN(fv) || isNaN(type)) {
resultValueDiv.textContent = "Error: Please enter valid numbers for all fields.";
return;
}
if (nper <= 0) {
resultValueDiv.textContent = "Error: Number of periods must be positive.";
return;
}
if (type !== 0 && type !== 1) {
resultValueDiv.textContent = "Error: Payment timing must be 0 or 1.";
return;
}
var pmt;
// Handle zero interest rate case
if (rate === 0) {
pmt = -(pv + fv) / nper;
} else {
// Standard PMT calculation
var numerator = rate * (pv * Math.pow(1 + rate, nper) + fv);
var denominator = (Math.pow(1 + rate, nper) – 1);
if (type === 1) { // Payment at the beginning of the period (annuity due)
if (denominator === 0) { // Avoid division by zero if (1+rate)^nper is 1
pmt = -(pv + fv) / nper; // This case is unlikely if rate is not 0, but for safety
} else {
pmt = numerator / (denominator / (1 + rate));
}
} else { // Payment at the end of the period (ordinary annuity)
if (denominator === 0) { // Avoid division by zero if (1+rate)^nper is 1
pmt = -(pv + fv) / nper; // This case is unlikely if rate is not 0, but for safety
} else {
pmt = numerator / denominator;
}
}
}
// Check for potential issues like division by zero or invalid intermediate calculations
if (isNaN(pmt) || !isFinite(pmt)) {
resultValueDiv.textContent = "Calculation Error: Check inputs.";
} else {
// Display the result, typically as a positive value for payment amount
resultValueDiv.textContent = "$" + Math.abs(pmt).toFixed(2);
}
}