Re: Sqrt(1  x^2) & Sqrt(1 + x^2) functions Message #6 Posted by Eduardo Duenez on 10 May 2012, 10:04 a.m., in response to message #4 by Paul Dale
It's true that a numerically stable formula for sqrt(1x^2)1 for small x can be given in terms of ln(x+1) and exp(x)1. However, a logarithm/exp combination is a very inefficient way to compute these functions! (E.g., the algorithm for x^2 is not exponentiating twice the log. For that matter, efficient algorithms for x^2 do not simply multiply x by itself.)
A related thought: On the opposite case, when abs(x) is close to 1, say for concreteness that x=1t for some small t, then evaluating sqrt(1(1t)^2) directly is numerically unstable, but never forget your algebra: rewrite in the stable form sqrt(t*(2t)).
