<div dir="ltr">Thank you. That made a huge difference.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 16 Aug 2020 at 15:24, John Maddock via Boost-users <<a href="mailto:boost-users@lists.boost.org">boost-users@lists.boost.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br> On 16/08/2020 21:15, Anirban Pal via Boost-users wrote:<br> ><br> > Hello,<br> ><br> > I’m using the tanh-sinh integrator to integrate a simple function f(x) <br> > = 0.26*x from 3.0 to 4.0.<br> > The exact result is 0.91. With the integrator I’m getting a result <br> > accurate to only 10^-18 with cpp_bin_float_100 multiprecision.<br> ><br> You have the double precision constant 0.26 in your code, and since this <br> is an inexact binary value, everything that depends on that constant is <br> inherently limited to double precision. Try constructing it as Real(26) <br> / 100.<br> <br> <br> > |typedef boost::multiprecision::cpp_bin_float_100 Real; int main(int <br> > argc, char **argv) { using namespace boost::math::quadrature; using <br> > namespace std::placeholders; tanh_sinh<Real> integrator; auto f2 = <br> > [](Real x) { Real a = 0.26; return x*a; }; std::cout << <br> > std::setprecision(std::numeric_limits<Real>::max_digits10) << "Comp.: <br> > " << integrator.integrate(f2, (Real) 3.0, (Real) 4.0) << std::endl; <br> > return 0; } |<br> > I'm getting an output of<br> ><br> > Comp.: <br> > 0.9100000000000000310862446895043831318616867065429687499999999999999999999999999999999999999999999999429<br> ><br> > which I'm a bit curious about. I was wondering if I can improve the <br> > result.<br> ><br> > Thank you.<br> ><br> ><br> > -- <br> > Anirban Pal<br> ><br> ><br> ><br> ><br> > _______________________________________________<br> > Boost-users mailing list<br> > <a href="mailto:Boost-users@lists.boost.org" target="_blank">Boost-users@lists.boost.org</a><br> > <a href="https://lists.boost.org/mailman/listinfo.cgi/boost-users" rel="noreferrer" target="_blank">https://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br> <br> -- <br> This email has been checked for viruses by Avast antivirus software.<br> <a href="https://www.avast.com/antivirus" rel="noreferrer" target="_blank">https://www.avast.com/antivirus</a><br> <br> _______________________________________________<br> Boost-users mailing list<br> <a href="mailto:Boost-users@lists.boost.org" target="_blank">Boost-users@lists.boost.org</a><br> <a href="https://lists.boost.org/mailman/listinfo.cgi/boost-users" rel="noreferrer" target="_blank">https://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br> </blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Anirban Pal</div><br></div></div></div></div></div></div></div></div><br><div><br></div></div></div></div></div></div></div></div></div></div></div>