Boost logo

Boost :

From: anshu khare (anshukhare1998_at_[hidden])
Date: 2020-01-17 12:32:34


I ran the following code :

#include <iostream>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
using boost::math::constants::pi;
using boost::multiprecision::cpp_bin_float_50;

int main()
{
cout << cos(3 * pi<cpp_bin_float_50>/2) << endl;

cout << cos(5 * pi<cpp_bin_float_50>/2) << endl;

cout << cos(7 * pi<cpp_bin_float_50>/2) << endl;

cout << cos(9 * pi<cpp_bin_float_50>/2) << endl;

return 0;
}

Output is as follows:

1.06911e - 50
1.06911e - 50
-1.06911e - 50
1.06911e - 50

Anshu

On Fri, 17 Jan, 2020, 3:29 PM John Maddock via Boost, <boost_at_[hidden]>
wrote:

>
> 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.
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk