|
Author |
Message |
Sondermad Member Posts: 7 Registered: Aug 2004 |
Posted March 24th, 2005 02:45 AM IP  Hi Bhuvanesh, a friend of mine has discovered a strange bug in Mathematica.
Here is what he writes:
>>>
I want to calculate the following (very simple) integral
f[x_,y_] := (Sign[1 - x^2-y^2] + 1)/2;
Integrate[f[x,y], {x, -1, 1},{y,-1,1}]
f is just a function which is equal to one inside the
unit circle and zero outside. Therefore the integral
should be equal to pi (the surface of the unit disc).
Guess what is the answer of mathematica (version 5): ZERO.....
However if I use Nintegrate to get a numerical evaluation
of the integral, the result is close to pi.
Moreover if I use the Heaviside function instead of
(Sign[1 - x^2-y^2] +1)/2
f[x_,y_] := UnitStep[1 - x^2-y^2]
Integrate[f[x,y], {x, -1, 1},{y,-1,1}]
Mathematica cannot find the result....
Therefore Mathematica does not know the simple relation:
UnitStep[x,y]=Sign[1 - x^2-y^2] +1)/2
Conclusion Pi=0
good luck with this new result
<<<
I can reproduce this strange bug, but I can’t tell what it’s caused by. So Bhuvanesh do you know where the problem is?!?
Regards, Mads
|
|
|
|
Bhuvanesh Moderator Posts: 117 Registered: Jul 2004 |
Posted April 6th, 2005 12:29 PM IP  Hi Mads,
Version 5.1 gives correct results for these integrals.
$Version = 5.1.0 for Microsoft Windows (October 25, 2004)
$TopDirectory = C:\Program Files\Wolfram Research\Mathematica\5.1.0
In[1]:= f[x_, y_] := (Sign[1 - x^2 - y^2] + 1)/2;
In[2]:= Integrate[f[x,y], {x, -1, 1},{y,-1,1}]
Out[2]= Pi
In[3]:= NIntegrate[f[x, y], {x, -1, 1}, {y, -1, 1}]
Out[3]= 3.14159
In[4]:= f[x_, y_] := UnitStep[1 - x^2 - y^2]
In[5]:= Integrate[f[x, y], {x, -1, 1}, {y, -1, 1}]
Out[5]= Pi
5.1 does the integrals using the new Piecewise functionality, so the underlying Integrate issues may just be masked. I'll take a look.
Thanks for letting me know. In the future, though, please report such bugs to support@wolfram.com -- they can be tracked better that way, and we can notify the reporter when they are fixed.
|
|
 |
|
|
|
|
TechniCalc Forum :: :: Bhuvanesh :: Bug in Mathematica?? |
|