Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Should total interest be derived from the rounded or the exact annuity payment?

+1
−0

I run a site with a small annuity loan calculator written in plain JavaScript. It shows two numbers: the monthly payment, and the total interest paid over the term.

The payment comes from the standard annuity formula:

var n    = years * 12;
var r    = annualRatePercent / 100 / 12;
var f    = Math.pow(1 + r, n);
var term = principal * r * f / (f - 1);

The payment is displayed rounded to whole units:

Math.round(term)

but the total interest is derived from the unrounded value:

Math.round(term * n - principal)

So the two displayed figures do not reconcile with each other. For a principal of 300000 at 14 percent over five years, the exact payment is 6980.4753. The page shows 6980 as the payment and 118829 as total interest. A reader who multiplies the displayed payment by 60 and subtracts the principal arrives at 118800, which is 29 lower. At 250000 and 16 percent over five years the error runs the other way, 29 too high.

The amounts are small, but people do check the arithmetic, and numbers that fail to add up look careless on a page about money.

As far as I can tell there are three options:

  1. Keep the exact payment for the totals and accept that the displayed figures do not reconcile.
  2. Round the payment first and derive everything from the rounded value, so the page is internally consistent but slightly off from what a lender would actually charge.
  3. Build an actual amortization schedule, round each instalment, and let the final instalment absorb the remainder.

The third is clearly the most accurate. What I am unsure about is whether it is the right choice for a display-only estimate, because it makes the last payment differ from every other one, and that then has to be explained in the interface.

Is there an established convention here? I would rather follow whatever amortization libraries have settled on than invent a rule of my own.

The deployed version is at https://samlegjeld.no/samle-gjeld-kalkulator/ if seeing the output helps.

History

1 comment thread

Currency (3 comments)

Sign up to answer this question »