MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to explain this weird effect? Integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46257] Re: [mg46245] how to explain this weird effect? Integrate
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 12 Feb 2004 22:46:17 -0500 (EST)
  • References: <200402121216.HAA12039@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 12 Feb 2004, at 13:16, steve_H wrote:

> I type:
>
> r = Integrate[Sin[m  x] Sin[n x], {x, 0, 2 Pi}]
>
> then I type
>
> r /. {n -> 2, m -> 2}
>
> I get error (1/0 expression encountered) and no result.
>
> but when I let m=2 and n=2 right into the integral first, it works:
>
> r = Integrate[Sin[2 x] Sin[2 x], {x, 0, 2 Pi}]
>
> and I get Pi as expected.
>
> I wanted to integrate this once, and try the output for different n,m.
>
> I did not think it will make a difference as to when I replace m and n
> by their numerical values, but Mathematica disagrees.
>
> I know Mathematica is correct in this, since it is clear from the 
> result
> of the integration why I get 1/0. But it seems to me I should
> get the same result if I replace m,n inside the integral before
> the integration operation starts, or replace them afterwords.
>
> For example, when I type
>
> Integrate[Sin[m x], {x, 0, Pi}]
> % /. m -> 4
>
> I get zero.
>
> and when I replace m with 4 inside the integral first, I get the same
> result as above:
>
> Integrate[Sin[4 x], {x, 0, Pi}]
> 0
>
>
> So, what do you think? is there something I am missing here?
>
> thanks
> Steve
>
>
>
It's not hard to explain if you actually look at the output you get 
before substituting values for n and m.

r = Integrate[Sin[m*x]*Sin[n*x], {x, 0, 2*Pi}]


(n*Cos[2*n*Pi]*Sin[2*m*Pi] - m*Cos[2*m*Pi]*Sin[2*n*Pi])/(m^2 - n^2)

So as you see Mathematica returned an answer with (m^2 - n^2) in the 
denominator. The numerator also becomes 0 when you sent n and m to the 
same value, but because of the way Mathematica evaluates fractions it 
sees 1/0 and complains. In any case, it returns Indeterminate. However,


Limit[r, n -> m] /. m -> 2

Pi

which, I hope, answers your question.


Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Re: options in NDSolve
  • Next by Date: Re: NMinimize/FindMinimum and function involving NDSolve
  • Previous by thread: Re: how to explain this weird effect? Integrate
  • Next by thread: Re: how to explain this weird effect? Integrate