Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

Strange error in Bessel function jn(n, x) for n >= 13

Stefan_I_
Beginner
931 Views

I encountered a strange error in the intrinsic Bessel function jn(n, x) of ICPC under Ubuntu Linux.

For moderately large orders "n" starting with 13 (spooky!) and arguments "x" slightly below n, the results is significantly wrong. See the example code and obtained results below:

------------------------------
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int
main(int argc, char* argv[])
{
  int n = 13; double x = 12.999999999;
  cout << setprecision(16) << scientific
       << setw(24) << jn(n, x) << ' '
       << setw(24) << jnl(n, (long double)(x)) << endl;
  return 0;
}
------------------------------

Compile command:
  icpc -O0 -o besselbug besselbug.cc

Result (comparison obtained with double vs long double version of jn()):
  6.1406433187032379e-02 1.9014887597058296e-01

Compiler and OS versions:
  icpc (ICC) 19.1.3.304 20200925
  OS: Ubuntu 20.04.1 LTS (but same effect under 18.04.5 LTS)
  g++ version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Hardware:
  Tested on AMD EPYC and Intel Xeon systems - no difference

Output of ldd:
linux-vdso.so.1 (0x00007fffe3198000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f97d0c22000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f97d0ad3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f97d0ab8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f97d08c6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f97d08c0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f97d0e32000)

Other compilers (g++, clang++) do not show this behaviour on the same systems.

 

0 Kudos
3 Replies
IntelSupport
Community Manager
907 Views

Hi Stefan,

 

Thank you for posting in Intel C++ Compiler forum. We were able to reproduce the issue that you've posted. We' re escalating the issue to the concerned internal team. We've also noticed that in Ubuntu 18.04.4 icpc is showing the correct result i.e

1.9014887597058297e-01  1.9014887597058296e-01

 

Regards

Gopika

 

0 Kudos
Viet_H_Intel
Moderator
901 Views

I've reported this issue to our Compiler Developer.

Thanks,


0 Kudos
Viet_H_Intel
Moderator
681 Views

This issue is fixed in oneAPI Update 3.

We are going to close this thread.

Thanks,


0 Kudos
Reply