Difference in answers to integral given by HP 50g emulator and octave

Why is there difference in the answer of the following integral given by Hp 50g emulator and Octave?
image
image
image
image
Answer given by Octave
image

It seems to be particularly hard to numerically integrate that function. Wolfram Alpha gives yet another result:
numeric value of integrate tan(ln(x)/cosh(x)) from 0 to 1 - Wolfram|Alpha (wolframalpha.com)
integral_0^1 tan(log(x)/cosh(x)) dx | decimal approximation = -0.637315

I’d guess that any numeric integration on a non-finite integrand is probably bound to have pretty high uncertainties. You can see that by slightly changing the waypoints for the integration and observing how much that affects the result.
E.g.:

>> f = @(x) tan (log (x) ./ cosh (x));
>> integral(f, 0, 1, 'Waypoints', [0.009, 0.2])
warning: quadgk: non-finite integrand encountered
warning: called from
    quadgk at line 348 column 7
    integral at line 182 column 11

warning: quadgk: Error tolerance not met.  Estimated error 0.696935
warning: called from
    quadgk at line 404 column 5
    integral at line 182 column 11

ans = -0.5256
2 Likes

I didn’t understand how did you arrive at the WayPoints [0.009,0.2]?

The function
image
is discontinued at x=0. But it is continuous at x= 0.009 and x=0.2.
Would you explain your computations of Waypoints?

I didn’t compute the waypoints. I let the function plot by Wolfram Alpha and just took the (approximate) values of the last two singularities as waypoints that might help finding “better” steps for the numeric integration:
plot tan(ln(x)/cosh(x)) from 0 to 1 - Wolfram|Alpha (wolframalpha.com)