Hi Alex, On 03/02/18 05:13, Alex Henrie wrote:
/********************************************************************* @@ -1429,8 +1437,18 @@ double CDECL MSVCRT__j1(double num) */ double CDECL MSVCRT__jn(int n, double num) { + double retval; /* FIXME: errno handling */ - return jn(n, num); +#ifdef HAVE_JN + retval = jn(n, num); +#else + if (n == 0) return MSVCRT__j0(num); + if (n == 1) return MSVCRT__j1(num); + retval = sqrt(2 / (M_PI * num)) * cos(num - (n / 2.0 + 0.25) * M_PI); + if (retval < -1) return -1; + if (retval > 1) return 1; +#endif + return retval; } This approximation can only be used for values in specific range to give reasonable results. There are similar problems with j0, j1 fallbacks (I haven't checked other functions).
I think it's better to print FIXME instead of adding very inaccurate fallback. Taking in account the functions are probably mainly used for physics related computations I guess it's better to avoid inaccurate implementation at all. Thanks, Piotr