In this post is the function I wrote to calculate APR based on some formulas I did find. One of my requirements was that this formula needed to produce exactly the same result as the Excel RATE function that I frequently encountered while trying to find an APR function.
This function was designed for fixed monthly payments. It will not work for variable rate loans.
NOTE: I assume no liability or responsibility for the accuracy or results produced by this function. It is up to you to test and verify that it returns the desired results. You are free to do whatever you wish with the function.
If you found this function to be useful and saved you some time and effort, feel free to donate to my beer fund using the PayPal link below.