This is a very old thread, but there's some great code in it! However, all these formulae apparently work on the principal branch. I need a formula that will work on the -1 branch (as well as the principal branch). Is there such a thing?