Is this a bug in defint?



I'm trying to do a definite integral, but defint tells me that one
limit of integration is not real.
This is an example:

(%i2) assume(a>0,b>0,c>0);
(%o2) [a > 0,b > 0,c > 0]
(%i3) l1 : sqrt(a^2+b^2);
(%o3) sqrt(b^2+a^2)
(%i4) l2 : sqrt(b^2+(c-b)^2);
(%o4) sqrt((c-b)^2+b^2)
(%i5) defint(x,x,0,l1);
(%o5) (b^2+a^2)/2
(%i6) defint(x,x,0,l2);
defint: upper limit of integration must be real; found sqrt((c-b)^2+b^2)
 -- an error.  To debug this try debugmode(true);

but:

(%i7) realpart(l2);
(%o7) sqrt((c-b)^2+b^2)
(%i8) is((c-b)^2+b^2>0);
(%o8) true


a, b and c are all assumed > 0, and Maxima correctly evaluates
sqrt(a^2+b^2) to be real, and also (c-b)^2+b^2 is >0, and its square
root has to be real, But defint thinks about it in a different way...

I suspect defint does this: instead to evaluate (c-b)^2+b^2 as the sum
of the square of two terms > 0, wich would lead to a result > 0,  it
does the expansion to c^2 + 2*b^2 - 2*c*b calling ratsimp, that is
equivalent to (c-b)^2+b^2, but doing so some information are lost: in
fact, Maxima cannot determine if c^2 + 2*b^2 is greater than  2*c*b,
thereforecannot determine if sqrt((c-b)^2+b^2) is real, as required by
defint.

I don't know lisp, but looking at Maxima's source code (version
5.19.0) I've found that in /src/defint.lisp there is the following
code (lines 207-210):


(cond ((not (equal (sratsimp ($imagpart ll)) 0))
		    (merror (intl:gettext "defint: lower limit of integration must
be real; found ~M") ll))
		   ((not (equal (sratsimp ($imagpart ul)) 0))
		    (merror (intl:gettext "defint: upper limit of integration must
be real; found ~M") ul)))


so the problem seems to be the call to ratsimp. In fact, while before we had:

(%i4) l2 : sqrt(b^2+(c-b)^2);
(%o4) sqrt((c-b)^2+b^2)
(%i38) realpart(l2);
(%o38) sqrt((c-b)^2+b^2)

now, after ratsimp is called we have:

(%i39) ratsimp(l2);
(%o39) sqrt(c^2-2*b*c+2*b^2)
(%i40) realpart(%o39);
(%o40) cos(atan2(0,c^2-2*b*c+2*b^2)/2)*sqrt(abs(c^2-2*b*c+2*b^2))
(%i41) imagpart(%o39);
(%o41) sin(atan2(0,c^2-2*b*c+2*b^2)/2)*sqrt(abs(c^2-2*b*c+2*b^2))

That's not so good. Now defint sees an imaginary part. In this way,
informations about the sign of the original expression are lost.

I hope I'm not telling stupid things... I'm not a matematician and I
don't know wich is the right way to do a definite integral, but l2 is
obviously real and ratsimp does some transformations that leave me
with some doubts.
Could be better to do the simplification in another way instead to call ratsimp?

Thanks for any help.

Stefano