Thanks to The Finance Buff for these formulas.
Here are some simple PHP functions to convert and APY to an APR and back
function apy_to_apr($rate, $periods = 365) { return ( $periods * pow( (1+$rate), (1/$periods) )) - $periods; } function apr_to_apy($rate, $periods = 365) { return ( pow( (1+ ($rate/$periods)), $periods) - 1); }
I’m having trouble following the equations.
would you please show me with a step by step process.
I also don’t understand some of the terms being used.
Thank you, Jerry B.
I’ve tried to use variable names that make sense:
$rate = The interest rate as a decimal (ie 5% as 0.05)
$periods = The number of compounding periods (365 would be compounded daily)
I didn’t come up with the formulas on my own. I found them at The Finance Buff and just converted them to PHP functions. I’ve tried them out and the results appear to be correct to me.
Thanks,
Brandon