calculate_loan_payment
Calculate the level periodic payment (PMT) that fully amortises a loan: the constant payment per period covering principal and interest over the loan term. Formula: PMT = P x [r(1 + r)^n] / [(1 + r)^n - 1]. WHEN TO USE: Use to size loan/mortgage payments, check affordability, or reverse-engineer what a borrower can service — given principal, periodic rate and number of periods. WHEN NOT TO USE: Do NOT use for interest-only facilities, balloon structures with uneven payments, or when you need the total interest paid rather than the payment itself. BEHAVIOUR: pure deterministic calculation — no side effects, no network or storage access; idempotent and non-destructive; identical inputs always produce identical outputs. Division by zero, non-finite inputs, or mathematically undefined combinations return an explicit error instead of a number. RETURNS: JSON object { loan_payment: number (currency per period), inputs }. PARAMETERS: principal (required): Loan principal amount, e.g. 500000. Must be > 0. rate (required): Periodic interest rate as a decimal, e.g. 0.005 = 0.5% monthly for a 6% annual rate (never pass percentage points). Must match period frequency. periods (required): Total number of payments, e.g. 60 for a 5-year monthly loan. Must be >= 1.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rate | Yes | Periodic interest rate as a decimal, e.g. 0.005 = 0.5% monthly for a 6% annual rate (never pass percentage points). Must match period frequency. | |
| periods | Yes | Total number of payments, e.g. 60 for a 5-year monthly loan. Must be >= 1. | |
| principal | Yes | Loan principal amount, e.g. 500000. Must be > 0. |