added pi derivation algorithms in JS