Maxima 5.20.1 with wxMaxima.
integrate(1/(a-b*cos(x)),x,0,%pi); where a>0, 0<b<a yields 0.
Notice how a float enters into the asksign:
Is a^2-1.0 positive or negative?neg;
The incorrect result comes from polelist failing to identify the locations of the poles.
Since the integrand is even, we can integrate from -%pi to %pi (or 0 to 2*%pi) and take half of the result. This integral is converted to the contour integral of -2/(b*yy^2-2*a*y+b) around the unit circle. This is evaluated by residues. We want to find the poles inside the unit circle and polelist is supposed to do that. The poles are correctly determined, but unfortunately for these poles, polelist cannot find the one pole that is in the circle. Therefore the function res thinks there are no poles in the unit circle and returns 0.
When a and b are numbers, polelist does a better job and normally determines the pole that is within the unit circle.
Perhaps the function that determines whether the pole is in the unit circle needs to be enhanced?
(defun unitcir (grand var)
(let ((result (princip (res nn* dn*
(eq (let ((limitp nil))
($asksign (m+ -1 (cabs pt))))
(alike1 1 (cabs pt)))))))
(cond (result (m* '$%pi result))
Yes, that works nicely. Need to make the second lambda also call asksign. And since the question is the same, it's nice to cache the answer from the first lambda.
dgildea's basic solution checked in.