|
Boost : |
From: John Maddock (jz.maddock_at_[hidden])
Date: 2020-01-17 09:59:04
On 17/01/2020 01:52, anshu khare via Boost wrote:
> On running cos(3*pi/2) , cos(5*pi/2) , cos(7*pi/2) , cos(9*pi/2) all give
> the same answer, which is less than epsilon except cos(7*pi/2) which gives
> a highly negative value.
Not seeing it, I'm running:
  for (unsigned i = 3; i < 20; i += 2)
  {
     std::cout << std::setw(20) << i << std::setw(20) <<
ceil(fabs(cos(i *
boost::math::constants::half_pi<boost::multiprecision::cpp_bin_float_50>())
/
std::numeric_limits<boost::multiprecision::cpp_bin_float_50>::epsilon()))
<< std::endl;
  }
Which gives:
                 N                abs error / epsilon
                  3                  2
                  5                  2
                  7                  2
                  9                  2
                 11                  6
                 13                 10
                 15                 10
                 17                  6
                 19                  6
And if I switch to testing type double I see:
                  3                  1
                  5                  2
                  7                  2
                  9                  3
                 11                 12
                 13                  5
                 15                 13
                 17                  4
                 19                 14
Best, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk