]> git.r.bdr.sh - rbdr/dotfiles/blob
42fbf1457f7604924555bda7d237798d0587ba3a
[rbdr/dotfiles] /
1 'use strict';
2
3 var log = Math.log, sqrt = Math.sqrt;
4
5 module.exports = function (x) {
6 if (isNaN(x)) return NaN;
7 x = Number(x);
8 if (x === 0) return x;
9 if (!isFinite(x)) return x;
10 if (x < 0) {
11 x = -x;
12 return -log(x + sqrt(x * x + 1));
13 }
14 return log(x + sqrt(x * x + 1));
15 };