Detected by Claude:
domain:real$
F : integrate(sqrt(x+1)/sqrt(x+2), x);
=> sqrt(x^2+3*x+2) - log(2*sqrt(x^2+3*x+2)+2*x+3)/2
float(subst(1,x,F) - subst(0,x,F)); => 0.7704339326490368
quad_qags(sqrt(x+1)/sqrt(x+2), x, 0, 1); => [0.7704339326490374, ...] ok
float(subst(-3,x,F) - subst(-4,x,F)); => -1.3001184281711244
quad_qags(sqrt(x+1)/sqrt(x+2), x, -4, -3); => [1.3001184281711287, ...] WRONG SIGN
For x < -2 both x+1 and x+2 are negative, so the two square roots are
imaginary and their quotient is real and positive. The printed antiderivative
is negative there.
pp-intir1-exec and mm-intir1-exec rewrite R1^E * R2^E as
(R1*R2)^E, in the line
(power ($expand (mul rofmax rofmin)) emin)
For E = N/2 with N odd that identity fails wherever R1 and R2 are
both negative: (-|R1|)^E * (-|R2|)^E is (-1)^N * (|R1|*|R2|)^E, so the
merged form is off by -1 there — and by nothing anywhere else.
This is not rootscontract. The merge is written out by hand in those two
functions, and nothing on the integrate -> inte -> intir-ref -> intir1
path calls rootscontract, radcan or simpnrt. A safe rootscontract
would not reach it.
Other integrands with the same shape, all wrong on the interval where both
radicands are negative:
sqrt(x-1)*sqrt(x+1) sqrt(x)*sqrt(x+4)/(x+2)
sqrt(x-2)/((x-1)*sqrt(x)) sqrt(x+1)*sqrt(x+2)