Home > Archive > Mathematica > November 2007 > case differentiation problem with "Assumptions"
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
case differentiation problem with "Assumptions"
|
|
| Paul.Wenk@googlemail.com 2007-11-27, 8:20 am |
| Hello,
I found the following problem using $Assumptions:
Let us calculate the integral: Integrate[Cos[(n \[Pi] (-W + y))/(2
W)]^2/W,{y,-W,W}]
for n \[Element] Integers and n>0 you receive 1, for n=0 you receive
2.
If you make the assumption
$Assumptions = n \[Element] Integers
then you get for the above integral the output 1, although for n=0
(also integer) it should be 2!
Why mathematica is not using a case differentiation in this case? How
is the information about the integer element inserted?
cheers,
Paul
p.s.
I'm using Mathematica 6.0.0 on Linux x86
| |
| Daniel Lichtblau 2007-11-28, 8:17 am |
| Paul.Wenk@googlemail.com wrote:
> Hello,
> I found the following problem using $Assumptions:
> Let us calculate the integral: Integrate[Cos[(n \[Pi] (-W + y))/(2
> W)]^2/W,{y,-W,W}]
> for n \[Element] Integers and n>0 you receive 1, for n=0 you receive
> 2.
> If you make the assumption
> $Assumptions = n \[Element] Integers
> then you get for the above integral the output 1, although for n=0
> (also integer) it should be 2!
> Why mathematica is not using a case differentiation in this case? How
> is the information about the integer element inserted?
>
> cheers,
> Paul
>
> p.s.
> I'm using Mathematica 6.0.0 on Linux x86
This comes up from time to time. The underlying issue is that
simplifications involving integrality specifications can and will give
results that are "generic", that is, possibly incorrect on a finite set.
Let's do the computation without the integrality assumption, then
post-simplify.
In[17]:= InputForm[ii = Integrate[Cos[(n*Pi*(-W + y))/(2*W)]^2/W,
{y,-W,W}, Assumptions->{W>0,n>0}]]
Out[17]//InputForm= 1 + (Cos[n*Pi]*Sin[n*Pi])/(n*Pi)
In[18]:= Simplify[ii, Assumptions->Element[n,Integers]]
Out[18]= 1
But as observed, the proper value at the origin is actually 2.
In[19]:= Limit[ii, n->0]
Out[19]= 2
The moral, such as it is, is that one should avoid such assumptions
inside Integrate (which will discard them anyway, except for final
post-processing). One should moreover apply them with caution after the
fact.
Daniel Lichtblau
Wolfram Research
| |
| David W.Cantrell 2007-11-28, 8:17 am |
| Paul.Wenk@googlemail.com wrote:
> I found the following problem using $Assumptions:
> Let us calculate the integral: Integrate[Cos[(n \[Pi] (-W + y))/(2
> W)]^2/W,{y,-W,W}]
> for n \[Element] Integers and n>0 you receive 1, for n=0 you receive 2.
> If you make the assumption
> $Assumptions = n \[Element] Integers
> then you get for the above integral the output 1, although for n=0
> (also integer) it should be 2!
> Why mathematica is not using a case differentiation in this case? How
> is the information about the integer element inserted?
>
> p.s.
> I'm using Mathematica 6.0.0 on Linux x86
I'm using version 5.2, but that may not make a difference.
Your observation seems to be that
In[7]:= Integrate[Cos[n Pi (-W + y)/(2 W)]^2/W, {y, -W, W},
Assumptions -> Element[n, Integers]]
Out[7]= 1
despite the fact that, if n == 0, the correct result is 2 instead.
Let's examine the source of this problem and a way in which this problem
could perhaps be eliminated in version 6.
Note that, without any assumption on n, we have
In[8]:= Integrate[Cos[n Pi(-W + y)/(2 W)]^2/W, {y, -W, W}]
Out[8]= 1 + Sin[2*n*Pi]/(2*n*Pi)
That result is valid for nonzero n, integer or not. But it fails if we
literally substitute 0 for n, giving Indeterminate. OTOH, if we take its
limit as n approaches 0, we do get the desired result, 2 .
Now, for In[8], there is a result which is _literally_ valid for all n:
1 + Sinc[2*n*Pi]
I have mentioned in this newgroup and others several times that it would be
useful to implement the sine cardinal function in computer algebra systems.
One use is illustrated above. And I see that version 6 now does implement
the sine cardinal function as Sinc. But perhaps, in version 6, In[8] still
produces Out[8]. If so, that would hardly be surprising, since Sinc was
such a recent addition. But I would hope that, eventually, Mathematica will
take full advantage of having Sinc implemented and that then the result of
In[8] would be 1 + Sinc[2*n*Pi].
Because it's probably related to why Out[7] was simply 1, also note that
In[9]:= Assuming[Element[n, Integers], Simplify[Sin[2 n Pi]/(2 n Pi)]]
Out[9]= 0
despite the fact that Sin[2 n Pi]/(2 n Pi) is literally Indeterminate
if n == 0.
And the above is probably related to
In[10]:= 0/x
Out[10]= 0
despite the fact that 0/x is literally Indeterminate if x == 0.
David W. Cantrell
|
|
|
|
|