Re: how to explain this weird effect? Integrate
- To: mathgroup at smc.vnet.net
- Subject: [mg46315] Re: how to explain this weird effect? Integrate
- From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
- Date: Fri, 13 Feb 2004 21:58:13 -0500 (EST)
- References: <c0ftbt$c7p$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
nma124 at hotmail.com (steve_H) wrote: You have gotten several responses showing how, rather than merely replacing m or n by specific values, the results you desire can be obtained by taking limits as m or n approach those values. However, your expectation that mere replacement should give the desired results is _not unjustified_. First, let's look at In[1]:= Integrate[Sin[m*x]*Sin[n*x], {x, 0, 2*Pi}] Out[1]= (n*Cos[2*n*Pi]*Sin[2*m*Pi] - m*Cos[2*m*Pi]*Sin[2*n*Pi])/(m^2 - n^2) This expression may be rewritten as Sin[2*Pi*(m - n)]/(2(m - n)) - Sin[2*Pi*(m + n)]/(2(m + n)) {Perhaps a clever person could show how to get Mathematica to do that rewriting, but I did it by hand.} To avoid problems when we substitute using n = m or n = -m, we can again rewrite the expression in terms of a function which is well known, but (unfortunately?) not implemented in Mathematica. It's the sine cardinal function, often abbreviated "sinc". In[2]:= SinC[x_] := If[x == 0, 1, Sin[x]/x] Using it, the result of the integration may then be written nicely as # Pi*(SinC[2*Pi(m - n)] - SinC[2*Pi(m + n)]) The above form is valid for all m and n; in other words, merely replacing m and n by specific values, we always get the correct result for the integral. In an ideal world, I think that SinC would be implemented in Mathematica, which would then give #, rather than what it currently gives, for Out[1]. David Cantrell > 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