Exact mortgage APRs and amortization, checked against 1.2 million loans
Mortgage law draws hard lines in arithmetic: an APR within 1/8 of a percentage point, a finance charge understated by no more than $100, a loan higher-priced once its APR is 1.5 points above the average prime offer rate. It also leaves the creditor choices, such as whether to count an odd first period. This paper builds an exact reference for both treatments, runs 1.2 million loans through it and through seven common tools, and counts where the answers part, measuring each tool against the convention it actually implements.
Abstract
On 1 December 2026 Riptide computed the Regulation Z annual percentage rate and the full amortization schedule of 1,200,000 generated mortgages exactly: every payment and every month's interest in integer cents, and every APR as a certified interval no wider than 2.3 × 10⁻¹¹ percentage points, so that every comparison with a legal line is decided by exact integer arithmetic. Each loan gets two exact APRs: one that counts the odd first period as Appendix J does, and one that disregards it, as 12 CFR 1026.17(c)(4) permits when the first period is not too long. The reference reproduces all four worked examples of Appendix J (c)(1). The same loans were computed by seven common tools, and each tool was measured against the convention it implements.
- float64 is not the problem. Given the same payments, a float64 Appendix J solver agrees with the exact APR to 8.3 × 10⁻¹¹ basis points on every loan and never changes a decision.
- Every APR tool is close to its own convention. On fixed-rate loans, the spreadsheet-style method (PMT, then RATE; numpy-financial, the npm
financialpackage and LibreOffice Calc give identical numbers) is within 0.021 bp of the exact APR with the odd period disregarded, and QuantLib, configured so its 30/360 day count counts the odd days exactly, is within 0.019 bp of the exact APR with the odd period counted. Neither leaves the 1/8-point tolerance on any of the 859,665 fixed-rate set-A loans, all of which may use either treatment. At the three decimals a disclosure prints, they still differ from their own exact convention on 1.4% and 2.7% of fixed-rate loans. - The choice of convention moves the answer most. Between the two permitted treatments the exact APR moves by a median of 2.2 bp and up to 19.1 bp, its third decimal differs on 96.6% of loans, and, on this deliberately near-the-line population, higher-priced status differs on 93,775 loans (sensitivity, not prevalence).
- Where the choice is not available, the shortcut fails. On a constructed stress set of 200,000 loans whose first period is too long to disregard, the spreadsheet-style method is outside the 1/8-point tolerance on 100,973 (50.5%), by up to 55 bp. Used on adjustable-rate loans, where Regulation Z requires a composite APR, it understates the finance charge by more than $100 on 49.9% (70,000 loans whose rate rises at the reset): a misapplication of the method. Its APR is outside the 1/4-point tolerance on up to 71.4%, an upper bound before § 1026.22(a)(4): on 51,312 of those loans the rate falls, the finance charge is overstated, and an overstated finance charge and the APR it affects are treated as accurate (§ 1026.18(d)(1)(ii)).
- Half a cent decides 7.2% of schedules. 16.6% of loans have at least one month whose exact interest is exactly half a cent. A binary float64 schedule with the very same rounding rules ends on a different total for 72,396 loans (7.2%), every one of them such a loan, by up to $0.96 on fixed-rate loans and $8.38 on adjustable-rate loans.
- Cost of exactness. 1.2 million loans, each with an exact schedule, two certified APRs and two higher-priced tests, in 67.7 s on a 32-vCPU AWS Graviton3. One exact APR costs about 33× a float64 Newton solve in the same language; the exact schedule about 2.7×.
This paper describes arithmetic, not compliance. It is not legal advice: whether a disclosed figure is accurate depends on the creditor's elections (for example under 1026.17(c)(3) and (c)(4), or the choice of the United States Rule method) and on the tolerances of 1026.22(a)(4)–(5), which this study does not apply.
What this lets you do
- Know exactly what each convention gives. For every loan the reference produces the APR with the odd period counted and with it disregarded, each as a proof-sized interval, so the disclosed figure, the tolerance test and the higher-priced test can be checked against the treatment the creditor actually elected, without any solver tolerance.
- Check a loan-origination system or calculator against a reference. Run its loans through the reference and get every disagreement with the loan's inputs, so each one can be reproduced and explained: which come from the convention (odd days, the final payment, compounding of a fractional period, rate resets) and which from floating point.
- Make schedules agree to the cent across systems. Servicing, investor reporting and payoff statements need the same cents everywhere. Exact integer schedules end on the same total on every machine and in every language, including the half-cent months where binary float64 goes either way.
The reference is a Riptide prototype and is not published. Evaluation builds are available through Request an evaluation.
Method
This section describes the methods at the level of the algorithm. The Raya source is not published.
Amortization in integer cents
Rates are held as integers in thousandths of a percent (6.375% is 6,375), so the monthly rate is exactly and every quantity is a ratio of integers. The conventions are common ones, stated so that any implementation can follow them:
- C1, payment. The exact level payment is a rational number; it is computed with big integers as with and rounded to the nearest cent, halves up.
- C2, interest. Each month's interest is for the balance in cents, rounded to the nearest cent, halves up. Because fits in 64 bits, this is one integer multiplication and one integer division; a month is a half-cent tie exactly when .
- C3, last payment. The last payment is the remaining balance plus its interest.
- C4, odd days. Interest for the odd days between consummation and the start of the first full month is , nearest cent, halves up, collected at consummation as a prepaid finance charge.
- C5, adjustable rate. After payments the payment is recomputed by C1 at the fully indexed rate on the remaining balance for the remaining months.
The amount financed is the principal minus prepaid finance charges (fees and odd-day interest); the finance charge is the sum of all payments minus the amount financed.
Two exact APRs
Appendix J's general equation for a single advance with monthly payments, a first period of full months plus a fraction of a month, reduces to
and the APR is percent. The reference solves it twice:
- Odd period counted. and : the days are divided by 30 and the fraction earns simple interest, as Appendix J (b)(5)–(b)(6) describe. A first period of more than a month is modelled as whole 30-day months plus a fraction.
- Odd period disregarded. and , as 1026.17(c)(4) permits; following comments 17(c)(4)-3 and -4, the irregularity is disregarded for the APR while the odd-day interest stays in the finance charge and the amount financed.
The present value decreases strictly in when every payment is positive, so each APR is the unique root. At a candidate rate , write and . Then is equivalent to the integer inequality
where the sum is accumulated by one multiply-by- and one shifted add per payment. Every test is therefore exact; no step rounds. A float64 Newton iteration gives a starting point, two exact tests confirm a bracket around the root (widened by factors of 100 until they do), and the bracket is printed rounded outward. The higher-priced test uses the same inequality at the rational rate , so "APR ≥ line" is decided exactly under each convention, without first computing the APR. A tool's APR, a float64, is compared with the bracket as an exact rational.
Which convention each tool implements, and what counts as a failure
| Tool | Convention it implements | Compared with |
|---|---|---|
| float64 Appendix J solver; float64, same rules | odd period counted | exact APR, odd period counted |
| QuantLib | odd period counted, fraction compounded | exact APR, odd period counted |
| Spreadsheet-style PMT/RATE; numpy-financial IRR | odd period disregarded | exact APR, odd period disregarded |
A tool's APR is outside the tolerance only if it is more than 1/8 of a percentage point (1/4 for adjustable-rate loans, treated as irregular transactions under 1026.22(a)(3); comment 22(a)(3)-1 limits that to variable-rate loans not disclosed on a regular amortization schedule, which fits these composite-schedule loans, so the 1/4 reading is the lenient one) away from every convention the loan may use: the counted convention always, the disregarded one only if the loan qualifies under 1026.17(c)(4). The mortgage-specific tolerances of 1026.22(a)(4)–(5), which tie the APR's accuracy to the finance charge's, are not applied; they can only make more disclosed APRs accurate.
Loans
- Set A, 1,000,000 loans that may use either treatment. Principals from a log-normal around $350,000 (most in whole dollars), note rates from 2.5% to 9% (three quarters on 1/8 steps, the rest on any thousandth), terms of 30, 15, 20 and 10 years, fees of 0–3% of principal on 90% of loans, 0–30 odd days, 20% of 30-year loans adjustable with a reset after 5, 7 or 10 years, and 10% subordinate liens. Every first period is at most 30 days longer than a regular month and every term is at least 10 years, so every set-A loan qualifies under 1026.17(c)(4)(iii).
- Set B, 200,000 fixed-rate loans that may not. Constructed so that none qualifies: half have 5- or 7-year terms and a first period 22–45 days longer than a month (the limit is 21 days under (c)(4)(ii)); half have 10–30-year terms and a first period 33–59 days longer (the limit is 32 days under (c)(4)(iii)). This is a stress set: its counts show what happens when the election is not available, not how common such loans are.
- Lines. Loans above $832,750, the FHFA 2026 baseline conforming loan limit, count as non-conforming. To test the higher-priced line hard, 40% of loans got an APOR that puts their APR within ±5 bp of it; higher-priced counts below therefore measure sensitivity near the line, not how often it happens in a real book.
Tools
| Lane | What it computes |
|---|---|
| float64, same rules | C1–C5 in float64 dollars, rounding halves up as , and an Appendix J Newton solve on that schedule |
| float64 Appendix J solver | the same solve on the exact schedule's payments |
| Spreadsheet-style PMT/RATE | pmt rounded to the cent, then rate(n, −payment, amount financed): first payment only, odd period disregarded, final payment taken as equal to the others (numpy-financial, npm financial, LibreOffice Calc PMT/RATE) |
| numpy-financial IRR | the IRR of the float schedule's monthly cash flows: final payment and reset included, odd period disregarded |
| QuantLib | CashFlows.yieldRate on the exact payments with their dates, 30/360 (US), monthly compounding, from consummation. The first full month starts on 1 May 2026 and consummation is set back the odd days through April (and March), 30-day months, so the day count is exactly the odd days; this is checked for every loan |
pip mortgage, pip amortization | each package's monthly payment and total paid |
QuantLib is the strongest general-purpose library in the test. Neither Python mortgage package computes an APR or models a rate reset.
Setup
| Machine | AWS c7g.8xlarge: Graviton3 (Neoverse-V1), 32 vCPU, Ubuntu 24.04, us-west-2 |
| Exact reference | Raya 0.4.0 (public release), compiled ahead of time; one process per vCPU |
| Tools | Python 3.12: numpy-financial 1.0.0, QuantLib 1.44, mortgage 1.0.5, amortization 3.0.1; Node 18.19.1 with financial 0.2.4; LibreOffice 24.2.7.2 headless |
| Loans | Set A 1,000,000 (859,665 fixed-rate, 831,933 of them with an odd first period; 140,335 adjustable); set B 200,000 fixed-rate. LibreOffice and both pip packages on the first 100,000 set-A loans (plus every tenth set-B loan for LibreOffice), the IRR lane on the first 20,000 set-A and every tenth set-B loan (it takes 141 ms per loan) |
| Tolerances | APR: 1/8 point, 1/4 for the adjustable loans (§ 1026.22(a)(2)–(3)); finance charge: $100 understated (§ 1026.18(d)(1), and § 1026.38(o)(2) for loans with a Closing Disclosure), and $35 after foreclosure starts, for rescission purposes only (§ 1026.23(h)(2)); higher-priced: APOR + 1.5 (first lien), + 2.5 (non-conforming first lien), + 3.5 (subordinate) (§ 1026.35(a)(1)); APR printed to three decimals (§ 1026.37(o)(4)(ii), § 1026.38(t)(4)(ii)) |
Checks. The reference reproduces the four Appendix J (c)(1) worked examples: brackets of 9.685708–9.685709%, 11.816508–11.816509%, 10.337902–10.337903% and 8.970769–8.970770% against the published 9.69%, 11.82%, 10.34% and 8.97%; and a $200,000 loan at 6% for 30 years pays $1,199.10. Twenty loans, ten from each set, were re-solved under both conventions by independent 60-digit decimal bisection: all 40 values fell inside the exact brackets. No tolerance decision was left undecided by the bracket width.
Results
Each tool against its own convention

| Method (convention) | APR error, median / worst | Outside 1/8 point | Third decimal differs | Higher-priced class differs |
|---|---|---|---|---|
| float64 Appendix J solver (counted) | 1.6 × 10⁻¹¹ / 8.3 × 10⁻¹¹ bp | 0 | 0 | 0 |
| float64, same rules (counted) | 1.8 × 10⁻¹¹ / 0.00096 bp | 0 | 15 | 0 |
| QuantLib (counted, fraction compounded) | 0.0018 / 0.019 bp | 0 | 23,010 (2.7%) | 79 |
| numpy-financial IRR (disregarded) | 1.8 × 10⁻¹⁰ / 0.00038 bp | 0 | 0 | 0 |
| Spreadsheet-style PMT/RATE (disregarded) | 0.0011 / 0.021 bp | 0 | 12,251 (1.4%) | 76 |
| LibreOffice Calc (disregarded; first 100,000) | 0.0011 / 0.019 bp | 0 | 1,166 (1.4%) | 5 |
Every tool is close to the convention it implements. The small differences that remain have plain causes. The spreadsheet method takes the final payment to be equal to the others, so its APR differs from its own exact convention by hundredths of a basis point, enough to move the printed third decimal on 1.4% of loans. QuantLib compounds the fractional first period, , where Appendix J applies simple interest, ; on loans without an odd period it agrees with the exact APR to 10⁻¹⁰ bp, and with one, the third decimal differs on 2.8% of them. All of either tool's higher-priced differences lie within 1 bp of the line.
An earlier, unpublished run of this study placed QuantLib's odd period in December, where the 30/360 day count loses a day; that, not QuantLib, made its third decimal differ on 90% of loans. With the dates set in 30-day months, as above, the difference is the compounding of the fraction alone.
The choice of convention
For the 1,000,000 set-A loans, both treatments are permitted, and the exact APRs they give differ by a median of 2.2 bp and up to 19.1 bp. The APR printed to three decimals differs on 966,345 loans (96.6%); the two exact values are more than the tolerance apart on 3,574; and, on this near-the-line population, the loan is higher-priced under one treatment and not the other for 93,775 loans. A tool that counts the odd period and one that disregards it will therefore rarely print the same APR, and both can be accurate. A comparison of two systems has to start from which election each one makes.
Where the choice is not available

On the 200,000 set-B loans the odd period must be counted. There the spreadsheet-style method, which disregards it, is outside the 1/8-point tolerance on 100,973 loans (50.5%), with the gap up to 55.2 bp; LibreOffice and the IRR lane give the same picture on their samples (10,113 and 10,112 of 20,000). The float64 solvers and QuantLib, which count the period, are within 0.037 bp on every set-B loan. Set B was built to sit outside the 1026.17(c)(4) limits; the share is a measure of what the shortcut does to such loans, not of how often they occur.
Adjustable-rate loans
The spreadsheet method sees only the first payment, so on adjustable-rate loans it ignores the reset that a composite APR must reflect (official comment 17(c)(1)-10). It understates the finance charge by more than $100 on 70,000 of 140,335 loans (49.9%), the loans whose rate rises at the reset. Its APR is outside the 1/4-point tolerance (comment 22(a)(3)-1; the lenient reading) on 100,178 (71.4%), by up to 135 bp, but that is an upper bound before § 1026.22(a)(4): on 51,312 of the 100,178 the rate falls at the reset, the finance charge is overstated, and § 1026.18(d)(1)(ii) treats an overstated finance charge and the APR it affects as accurate. That is a misapplication of the method, not a rounding effect: the IRR lane, which includes the reset, has no tolerance failures on adjustable-rate loans in a sample of 2,859, and the float64 solvers and QuantLib none either.
The finance-charge tolerance was never crossed on fixed-rate loans by any method: even the spreadsheet method's total, payment × months, is at most $9.96 away from the exact total.
Half a cent

Interest of cents is exactly half a cent in 257,182 loan-months spread over 166,308 set-A loans (16.6%). Rounding halves up, the exact schedule always goes up. In binary float64, lands a hair above or below the half, so the same rule goes either way; when it goes down, the balance is one cent higher from then on and the schedule drifts. 72,396 loans (7.2%) end on a different total, every one of them a tie loan: up to $0.96 on fixed-rate loans and $8.38 on adjustable-rate loans, where the reset payment is recomputed on a different balance. No legal tolerance is touched. Two systems that both round halves up on exact decimal amounts will agree; a system that does the same arithmetic in binary floating point will not reconcile with them to the cent. The pip amortization package differs from the exact schedule on 10.0% of fixed-rate loans (up to $0.72) and pip mortgage on 99.4% (up to $8.00).
Speed
| Per loan, median (set A) | Exact (Raya) | float64 (Raya, same rules) |
|---|---|---|
| Amortization schedule | 24 µs | 9 µs |
| One APR | about 1,060 µs | 32 µs (Newton solve) |
| Schedule + two APRs + two higher-priced tests | 2,149 µs | — |
For reference, the tools as used here: npm financial 5.8 µs, LibreOffice 36 µs, numpy-financial 611 µs, QuantLib 3,438 µs and the IRR lane 141 ms per loan (Python per-loan timings include interpreter overhead). 1.2 million exact loans, two APRs each, took 67.7 s on 32 vCPUs.
Limitations and next steps
The limits of these results, each with its cause and, where one is planned, the next step.
- Exact costs CPU time. One exact APR is about 33× the CPU time of a float64 Newton solve in the same language, and the exact schedule about 2.7×. Cause: each exact test multiplies integers of about 20,000 bits; the float solve is a few hundred floating-point operations.
- One set of rounding conventions. The reference implements one common set of conventions (C1–C5). Lenders and servicers use others (rounding the payment up, daily simple interest, payment application rules, ARM caps and floors), and each needs to be added and checked. Cause: scope of this first study.
- Two of the permitted APR treatments, not all. The reference computes the actuarial APR with the odd period counted and disregarded. The United States Rule method, the 1026.17(c)(3) simplifications (whole-cent payments, business-day shifts, months of different lengths, leap years), multiple advances and the finance-charge-based tolerances of 1026.22(a)(4)–(5) are not implemented. Cause: scope of this first study.
- Generated loans, not a lender's book. The loans are realistic but generated; 40% were placed near the higher-priced line, and set B was built to fall outside the 1026.17(c)(4) limits. Counts near the line and in set B measure sensitivity, not prevalence in practice. Cause: no lender data was used.
- No regulator software in the comparison. The FFIEC/CFPB APR tool is a web form and was not automated; the Appendix J worked examples were used instead. Cause: not yet automated.
- The tools were used as documented, not as a vendor's system would wrap them. A loan-origination system may add the odd period on top of a spreadsheet RATE, for example. Cause: no vendor system was tested.
Reproduce it yourself
Run kits/exact-mortgage-apr from the public riptide-reproduce repository: one command, a few minutes on a laptop, public software only. It reproduces the half-cent ties that send float64 schedules to a different total, the gap between the two permitted APR conventions, and the spreadsheet method on loans that may not disregard the odd period, with every tool's value and error per loan; the integer-cent schedules also run in Raya 0.4.0 and print the same totals. Every baseline's value and its error against the exact answer are printed and saved to errors.csv, and the exact results print the same hash on every machine: if your float hash differs from ours or a colleague's, that is precision drift in your pipeline.
Reproduction notes
- Software. The exact reference is a Riptide prototype in Raya and is not published. Evaluation builds are available through Request an evaluation.
- Records. The loan file (seeded generator and its SHA-256), every lane's per-loan output, the exact reference's output under both conventions, up to 5,000 disagreement examples per lane and kind with each loan's full inputs and whether it qualifies under 1026.17(c)(4), version records and the machine record. Evaluation partners can have the files on request.
- Cost. About $2.10 of AWS time.
References
- Truth in Lending Act, 15 U.S.C. 1606 (determination of annual percentage rate).
- Regulation Z, 12 CFR part 1026: § 1026.17(c)(3)–(4) and official comments 17(c)(1)-10, 17(c)(4)-3, 17(c)(4)-4 and 22(a)(3)-1 (permitted simplifications, irregular first periods, composite APRs for variable-rate loans); § 1026.18(d) (finance-charge tolerance); § 1026.22(a)(1)–(5) (APR determination, the good-faith calculation-tool provision, and the APR tolerances, including those for mortgage loans); § 1026.23(h) (tolerances after foreclosure starts, for rescission); § 1026.35(a) (higher-priced mortgage loans); § 1026.37(o)(4)(ii) and § 1026.38(o)(2), (t)(4)(ii) (Loan Estimate and Closing Disclosure: finance-charge tolerance and rounding of percentages to three decimals); and Appendix J (annual percentage rate computations for closed-end credit), including the worked examples in (c)(1).
- Federal Housing Finance Agency, "FHFA Announces Conforming Loan Limit Values for 2026", news release, 25 November 2025 ($832,750 baseline).
- QuantLib, the free/open-source library for quantitative finance, version 1.44.
- numpy-financial 1.0.0 (
pmt,rate,irr); npmfinancial0.2.4; LibreOffice CalcPMTandRATE.
Date and version
Version 1.2, 1 December 2026. Measurements from 1 December 2026. Updated 1 December 2026: limitations section retitled. Updated 1 December 2026: added "Reproduce it yourself".
Working with Riptide
Riptide works with a small number of teams. Each engagement starts with 4 weeks inside your systems, learning how your models, data and infrastructure work. Only then does Riptide apply its software to them. Contact samario@riptidecompute.com or riptidecompute.com/evaluate.