UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

17 lines (12 loc) 590 B
<!-- Generated by Rakefile:build --> <strong> Mike Speciner </strong> on 2011-07-20 03:45:02 <br /> This does not work for negative arg. It also suffers from poor precision for |arg| &lt;&lt; 1. To fix the first problem, try return Math.log(Math.abs(arg) + Math.sqrt(arg * arg + 1))*(arg&lt;0?-1:1); The second problem is much harder to fix; best might be a rational function approximation for small args. If there were a builtin function log1p(x) := log(1+x), and similarly expm1(x) := exp(x)-1, things would be much simpler for all the hyperbolic functions and their inverses. <hr />