       Re: Why is Mathematica assuming k==l and how do I make it not to?

• To: mathgroup at smc.vnet.net
• Subject: [mg92612] Re: Why is Mathematica assuming k==l and how do I make it not to?
• From: "David W.Cantrell" <DWCantrell at sigmaxi.net>
• Date: Wed, 8 Oct 2008 06:25:23 -0400 (EDT)
• References: <gcffpl\$f4g\$1@smc.vnet.net>

```Aaron Fude <aaronfude at gmail.com> wrote:
> As in
>
> Assuming[Element[{k, l}, Integers] ,
>  Integrate[Cos[k alpha] Cos[l alpha], {alpha, -Pi, Pi}]]
>
> I get 0 whereas the answer is Pi if k=l;

Your sort of question arises fairly often in this newsgroup. For example,
last month, it arose in the thread "Integration in Mathematica". See my
response then at

In your specific example, it seems that Mathematica is assuming that k and
l are different, even though they could be equal. Thus, I suppose you
really intended your title to be "Why is Mathematica assuming k != l and
how do I make it not to?"

The basic trouble in your example lies not in k and l being integers or in
the definite integral, but rather in the indefinite integral

In:= Integrate[Cos[k alpha] Cos[l alpha], alpha]
Out= Sin[alpha*(k - l)]/(2*(k - l)) + Sin[alpha*(k + l)]/(2*(k + l))

Note that the above is problematic if |k| = |l|. This problem could have
been avoided if Mathematica had given the result in terms of the sine
cardinal function, Sinc, newly implemented in version 6. Specifically, the
indefinite integral is given by

indef[alpha_, k_, l_] := alpha/2*(Sinc[alpha (k-l)] + Sinc[alpha (k+l)]);

Then, using the Fundamental Theorem, your desired definite integral is

In:= def = indef[Pi, k, l] - indef[-Pi, k, l]
Out= Pi*(Sinc[(k - l)*Pi] + Sinc[(k + l)*Pi])

If k and l are integers, then the above yields 0 or Pi, depending resp. on
whether the absolute values of k and l are different or the same.

David W. Cantrell

```

• Prev by Date: Re: Get Graphics Coordinates accuracy
• Next by Date: Re: integration
• Previous by thread: Re: Why is Mathematica assuming k==l and how do I make it not to?
• Next by thread: Format Type of new Output Cells to OutputForm