Calculating the monthly principle and interest payment (PNI)

If you're curious, here's the formula the mortgage calculator uses to calculate the monthly principle and interest payment (PNI):

This formula assumes interest is compounded once a month at the end of the month.