# [Maxima] integrate returns undefined

Raymond Toy raymond.toy at ericsson.com
Thu Sep 11 09:40:53 CDT 2008

```Edwin Woollett wrote:
> integrate(..) returns undefined when it
>
> (%i1) declare( [ m, n ], integer )\$
> (%i2) assume ( m > 0,  n > 0 )\$
> (%i3) integrate( cos(m*x)^2, x, 0, 2*%pi );
> (%o3)                                 %pi
> (%i4) integrate( cos(m*x)*cos(n*x), x, 0, 2*%pi  );
> Is  n - m  positive, negative, or zero?
>

FWIW, here is what is happening.  integrate eventually decides that the
antiderivative should be computed and the limits substituted.  Maxima
tries to be careful with the limits by calling sin-cos-intsubs1.  This
splits the integrand into numerator and denominator.  The limits are
substituted into the numerator and evaluates to zero because we have
expressions like sin(2*%pi*n), which is zero from the declaration on n.

Since the numerator is 0, we check the denominator.  Maxima can't tell
if the denominator is 0 or not, so it asks.  You respond with zero, so
we know that we have the form 0/0.  Hence it returns undefined.

Now suppose we respond with pos instead of zero.  Well, the denominator
is no longer 0, so the answer is then 0.

Anyway, that's why maxima returns undefined or 0 for this integrand.  I
can't think of any way to fix this.

Ray
```