You're right! I only considered that the relative errors of (a-b)/b and a/b-1.0 are the same magnitude. > Using log1p remains more accurate when a approx b because it is as accurate (In reply to Gael Guennebaud from comment #5) This also shows that the current atanh2 is clearly not very good. Scalar atanh2(const Scalar& x, const Scalar& r)ĭouble r4 = (a-b)/b // Taylor of log(a/b) for a=bĭouble r5 = 1.0/b - (a-b)/(2*b*b) // Taylor of log(a/b)/(a-b) for a=b Here is a selfcontained example comparing different implementations of log(a/b) and log(a/b)/(a-b): Using log1p remains more accurate when a approx b because it is as accurate as the first order Taylor approx of log(a/b), and log(a/b) is also needed in MatrixPower.h (without the division by a-b). I guess it's not enough to just check the C++ version, maybe not-android check should be done as well. Workdir/Eigen/src/Core/MathFunctions.h>:373:18: error: 'std::log1p' has not been declared Workdir/Eigen/src/Core/MathFunctions.h>: In static member function 'static Scalar Eigen::internal::atanh2_impl::run(const Scalar&, const Scalar&)': If (r = 0 || abs(z) > sqrt(NumTraits::epsilon())) Static inline Scalar run(const Scalar& x, const Scalar& r) Here's the code of atanh2_impl in MathFunctions.h (starts at line 362)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |