Boost logo

Boost Users :

From: Anirban Pal (anirban.pal.iitkgp_at_[hidden])
Date: 2020-08-16 21:00:33


Thank you. That made a huge difference.

On Sun, 16 Aug 2020 at 15:24, John Maddock via Boost-users <
boost-users_at_[hidden]> wrote:

>
> On 16/08/2020 21:15, Anirban Pal via Boost-users wrote:
> >
> > Hello,
> >
> > I’m using the tanh-sinh integrator to integrate a simple function f(x)
> > = 0.26*x from 3.0 to 4.0.
> > The exact result is 0.91. With the integrator I’m getting a result
> > accurate to only 10^-18 with cpp_bin_float_100 multiprecision.
> >
> You have the double precision constant 0.26 in your code, and since this
> is an inexact binary value, everything that depends on that constant is
> inherently limited to double precision. Try constructing it as Real(26)
> / 100.
>
>
> > |typedef boost::multiprecision::cpp_bin_float_100 Real; int main(int
> > argc, char **argv) { using namespace boost::math::quadrature; using
> > namespace std::placeholders; tanh_sinh<Real> integrator; auto f2 =
> > [](Real x) { Real a = 0.26; return x*a; }; std::cout <<
> > std::setprecision(std::numeric_limits<Real>::max_digits10) << "Comp.:
> > " << integrator.integrate(f2, (Real) 3.0, (Real) 4.0) << std::endl;
> > return 0; } |
> > I'm getting an output of
> >
> > Comp.:
> >
> 0.9100000000000000310862446895043831318616867065429687499999999999999999999999999999999999999999999999429
> >
> > which I'm a bit curious about. I was wondering if I can improve the
> > result.
> >
> > Thank you.
> >
> >
> > --
> > Anirban Pal
> >
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > https://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> --
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Anirban Pal


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net