]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix jn() precision problems around zero points of j0()
authorPetr Baudis <pasky@ucw.cz>
Sun, 22 Aug 2010 14:44:15 +0000 (16:44 +0200)
committerPetr Baudis <pasky@suse.cz>
Tue, 16 Nov 2010 01:50:16 +0000 (02:50 +0100)
commit9fcff7a79b60cd9202fdacafdbd5fb369933c64b
treebb07b9f932cea94dae8e48466ad8d0ba3b688da7
parent75134e46476263ab116be341531cadb1e6ab87d6
Fix jn() precision problems around zero points of j0()

There appears to be a really nasty bug in jn() from fdlibm, which is
the foundation for most libm implementations (including glibc libm).
The zeroth-order j0() and first-order j1() cylindrical Bessel functions
are used to recursively generate the jn() value, but only the zeroth-order
Bessel function is used to normalize it; however, each of the functions
gets highly imprecise (approaching "bogus") near its zero point, making
the jn() value itself bogus.

But in fact, the zero points of j0() and j1() never coincide, thus j1()
should be used in case it is more precise than j0(). (That is, simply
when its value is further from zero.)

As an example, 2.4048255576957729_8 is the first zero of j0().
The proper value as calculated by Mathematica is 0.19899990535769...
However, jn() returns -inf on 64-bit arch, or 0.185007 on 32-bit arch.
With the proposed patch below, the returned value is 0.199000.

The fix is based on work by Steve Kargl and Tobias Burnus.
ChangeLog
sysdeps/ieee754/dbl-64/e_jn.c
sysdeps/ieee754/flt-32/e_jnf.c
sysdeps/ieee754/ldbl-128/e_jnl.c
sysdeps/ieee754/ldbl-128ibm/e_jnl.c
sysdeps/ieee754/ldbl-96/e_jnl.c