Select Page

The Transparent APR Calculation

by | Nov 23, 2020

I recently hunkered down to solve the APR calculation. Ever since I started working in the lending industry nearly two decades ago, I wanted to explore it but never had the time. Before I started the work, however, I asked many of our lending customers how they handle this.

Many responded that it’s more trouble than it’s worth. Most customers rely on their document vendor to do the calculation or some other third-party API. Why they did this was largely due to a lack of transparency between their internal calculation and what the document vendors provided. Mis-matched APR calculation results between the Loan Origination System (LOS) and the rendered documents ultimately caused too many problems. In my mind, what we really need, is a more transparent calculation to support comparisons and discover drift between implementations.

Therefore, I set out to create a transparent APR calculation for the world to see, and if necessary, correct and/or improve it. Moreover, by digging deeper I uncovered a rich history of the calculation itself. To my surprise, the Truth in Lending Act, while protecting consumers, also requires lenders to do calculus.

In my search to solve the problem, I focused on examples that could mostly explain both the equation and the programmatic interpretation. The best examples used the Newton Raphson method. My final calculation and steps were based on the following formula:

APR Calculation

To set this up, I created the ruleset required to make the calculation. I then created local variables I could use for setting values (note I used ‘principal’ in the ruleset and ‘amount’ in the equation above).

APR Schema Structure

After creating the initial variables to feed the calculation, I set their values to input from the 1003 loan application:

APR Language Rule

Once those variables were set, I finished the equation with ‘f’ the numerator and ‘fp’ the denominator of the derivative, and then X which was our candidate APR. I set the initial X as follows (I had to start with something) and when starting ‘previousx’ was also set to X.

Set APR Value

Next, I set up the iteration using a while loop. The loop continued while the flag was set to 0.

While Loop

Then I completed the equation. ‘f’ (the numerator) was set to the following expression:

Set F Value


‘fp’ (the denominator) was set to the following expression:

Set fp Value

I remembered X for the next iteration by setting ‘previousx’ to its value. Finally, I set the new X based on putting it all together:

Set X Value

While looping, I tested the difference between ‘X’ (our current guess) and ‘previousx’ down to a level of precision required for confidence. When I hit the threshold, I toggled ‘flag’ to a 1 to stop the loop and set the APR using ‘X’.

Set APR Value


As with all things complicated, it helps to break everything down into pieces and then use those parts to complete an implementation. What makes this calculation transparent? By definition, it’s “…allowing light to pass through so that objects behind can be distinctly seen.” Everyone can see which variables are used and what the explicit expressions are in the calculation. Moreover, I can use irVerify to run examples through the ruleset to determine results and inspect state changes.

If you want to know more about this calculation, please reach out to us at info at inrule dot com.




We’d love to share company and product updates with you! Please enter your email address to subscribe to monthly updates from InRule. 

If at any time you want to unsubscribe, you can easily do so by clicking “unsubscribe” at the bottom of every message we send or visiting this page.