numerical algorithms in javascript