[math-fun] Calculating asinh(x)
y = asinh(x) = log(x + sqrt(1+x^2)) the "obvious" formula. We have several choices: * Calculate using the obvious log formula * Calculate using Newton's method on sinh(y) * More complicated methods One more complicated method is to factor the above expression as: y = asinh(x) = f(g(x)), where f(x) = log(x) and g(x) = x+sqrt(1+x^2) Note that if y=g(x), then x=(y-1/y)/2. So we could first invert g(x) using Newton's method, and then apply the log function. The iteration to invert y=g(x) is x -> 2*(y+(x-y)/(1+x^2)) with an initial guess of 2*y. This iteration has quadratic convergence, and 6 iterations provides fpprec=128 precision. It remains to be seen if this is faster and/or more precise than the obvious formula. The other possibility is to get a very good approximation, and finish it off with a very small (1,2,3 ?) iterations of Newton to invert y=sinh(x). The iteration is x -> x-tanh(x)+y/cosh(x), with quadratic convergence: x0+eps -> x0+eps^2*tanh(x0)/2
For what it's worth, I looked up how I compute asinh in my javascript library, based on the observations... asinh(x) = sgn(x) ln(|x| + sqrt(x^2+1)) which works best when |x| is "large" asinh(x) = atanh(x/sqrt(1+x^2)) which works best when |x| is "small", using atanh(x) = (ln ((1+x)/(1-x))/2 = (ln(1+x) - ln(1-x))/2 So, trying to get good precision... Math.atanh = function(x) { return .5*(Math.log1p(x)-Math.log1p(-x)); } Math.asinh = function(x) { var s = Math.sqrt(1+x*x); return s<Math.SQRT2 ? Math.atanh(x/s) : Math.sgn(x)*Math.log(Math.abs(x)+s); } On 03-Apr-17 12:32, Henry Baker wrote:
y = asinh(x) = log(x + sqrt(1+x^2))
the "obvious" formula.
We have several choices:
* Calculate using the obvious log formula * Calculate using Newton's method on sinh(y) * More complicated methods
One more complicated method is to factor the above expression as:
y = asinh(x) = f(g(x)), where f(x) = log(x) and g(x) = x+sqrt(1+x^2)
Note that if y=g(x), then x=(y-1/y)/2.
So we could first invert g(x) using Newton's method, and then apply the log function.
The iteration to invert y=g(x) is
x -> 2*(y+(x-y)/(1+x^2))
with an initial guess of 2*y.
This iteration has quadratic convergence, and 6 iterations provides fpprec=128 precision.
It remains to be seen if this is faster and/or more precise than the obvious formula.
The other possibility is to get a very good approximation, and finish it off with a very small (1,2,3 ?) iterations of Newton to invert y=sinh(x).
The iteration is x -> x-tanh(x)+y/cosh(x), with quadratic convergence:
x0+eps -> x0+eps^2*tanh(x0)/2
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
participants (2)
-
Henry Baker -
Mike Speciner