Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug in Mathematica 6 - NIntegrate - 3 (regression bug, invalid value)

1 view
Skip to first unread message

Vladimir Bondarenko

unread,
Jul 29, 2007, 11:37:09 PM7/29/07
to
Our little demo continues... Hello again from the VM machine
which is still ignored by CAS manufacturers.

----------------------------------------------------------------

N[MeijerG[{{1/2}, {}}, {{0, 0}, {-1}}, 1]/(2 Sqrt[Pi]), 30]

0.873218025861136139271426304072

----------------------------------------------------------------

NIntegrate[Log[1 + z^2] BesselJ[1, z]^2/z, {z, 0, Infinity}]

----------------------------------------------------------------
VERSION OUTPUT RESOLUTION
----------------------------------------------------------------

Mathematica 6.0 0.869058 <------------------------------ BUG

Mathematica 5.2 0.873025 OK

Mathematica 4.2 0.873025 OK

Mathematica 3.0 0.873025 OK

----------------------------------------------------------------

(**************************************************************)

Best wishes,

Vladimir Bondarenko

VM and GEMM architect
Co-founder, CEO, Mathematical Director

http://www.cybertester.com/ Cyber Tester, LLC
http://maple.bug-list.org/ Maple Bugs Encyclopaedia
http://www.CAS-testing.org/ CAS Testing

dimitris

unread,
Jul 30, 2007, 2:32:31 PM7/30/07
to

Hello comrade Vladimir.

I don't want to play the devil's advocate!

But, I guess that here you consider as a bug that Mma 6 does not give
a message which would indicate that the result could be wrong
something like

"NIntegrate::ploss: Numerical integration stopping due to loss of
precision. \
Achieved neither the requested PrecisionGoal nor AccuracyGoal; suspect
one of \
the following: highly oscillatory integrand or the true value of the
integral \
is 0. If your integrand is oscillatory try using the option \
Method->Oscillatory in NIntegrate."

That NIntegrate returns an incorrect result itself, it is not a bug
for me.
By playing with the options / changing the default integration
algorithm, I am sure that NIntegrate would return a correct numerical
estimation.

Dimitris

Vladimir Bondarenko

unread,
Jul 30, 2007, 2:53:36 PM7/30/07
to
Hi Dimitris,

A bit of clarification.

Behaviour of Mathematica 5.2/4.2/3.0 is not a bug because
while it returns not fully correct answer, 0.873025 instead
of 0.873218, Mathematica warns honestly on account of a
possible numeric error with

"NIntegrate failed to converge" etc

In contrast, in Mathematica 6,

NIntegrate[Log[1 + z^2] BesselJ[1, z]^2/z, {z, 0, Infinity}]

returns an invalid result, 0.869058, WITHOUT any warning
message.

This is why it is a BUG.

By the way, again here we speak as usually about a family
of bugs, say

NIntegrate[Log[1 + z^2] BesselJ[0, z]^2/z, {z, 0, Infinity}]
NIntegrate[Log[1 + z^2] BesselJ[2, z]^2/z, {z, 0, Infinity}]
NIntegrate[Log[1 + z^2] BesselJ[3, z]^2/z, {z, 0, Infinity}]

manifest the same bug (invalid value AND no warning).

Best wishes,

Vladimir Bondarenko

VM and GEMM architect
Co-founder, CEO, Mathematical Director

http://www.cybertester.com/ Cyber Tester, LLC


http://maple.bug-list.org/ Maple Bugs Encyclopaedia
http://www.CAS-testing.org/ CAS Testing


On Jul 30, 11:32 am, dimitris <dimmec...@yahoo.com> wrote:
> On 30 , 06:37, Vladimir Bondarenko <v...@cybertester.com> wrote:
>
>
>
> > Our little demo continues... Hello again from the VM machine
> > which is still ignored by CAS manufacturers.
>
> > ----------------------------------------------------------------
>
> > N[MeijerG[{{1/2}, {}}, {{0, 0}, {-1}}, 1]/(2 Sqrt[Pi]), 30]
>
> > 0.873218025861136139271426304072
>
> > ----------------------------------------------------------------
>
> > NIntegrate[Log[1 + z^2] BesselJ[1, z]^2/z, {z, 0, Infinity}]
>
> > ----------------------------------------------------------------
> > VERSION OUTPUT RESOLUTION
> > ----------------------------------------------------------------
>
> > Mathematica 6.0 0.869058 <------------------------------ BUG
>
> > Mathematica 5.2 0.873025 OK
>
> > Mathematica 4.2 0.873025 OK
>
> > Mathematica 3.0 0.873025 OK
>
> > ----------------------------------------------------------------
>
> > (**************************************************************)
>
> > Best wishes,
>
> > Vladimir Bondarenko
>
> > VM and GEMM architect
> > Co-founder, CEO, Mathematical Director
>

> >http://www.cybertester.com/Cyber Tester, LLChttp://maple.bug-list.org/ Maple Bugs Encyclopaediahttp://www.CAS-testing.org/CAS Testing

Nasser Abbasi

unread,
Jul 30, 2007, 3:46:08 PM7/30/07
to

>
> That NIntegrate returns an incorrect result itself, it is not a bug for me.
>

I cut the above and put in a big frame in front of me. Just to remind
me in the future that when I write a function that returns an
incorrect result and a user complains, I can just send them a copy of
the above and all will be well.

This must be the new modern software engineering definition of what is
not a bug. A function that returns an incorrect result is a feature,
not a bug.

> By playing with the options / changing the default integration
> algorithm, I am sure that NIntegrate would return a correct numerical
> estimation.
>
> Dimitris

But if an incorrect answer is not a bug, why should the user have to
do anything?

Nasser

dimitris

unread,
Jul 30, 2007, 4:13:15 PM7/30/07
to
On 30 , 21:53, Vladimir Bondarenko <v...@cybertester.com> wrote:
> Hi Dimitris,
>
> A bit of clarification.
>
> Behaviour of Mathematica 5.2/4.2/3.0 is not a bug because
> while it returns not fully correct answer, 0.873025 instead
> of 0.873218, Mathematica warns honestly on account of a
> possible numeric error with
>
> "NIntegrate failed to converge" etc
>
> In contrast, in Mathematica 6,
>
> NIntegrate[Log[1 + z^2] BesselJ[1, z]^2/z, {z, 0, Infinity}]
>
> returns an invalid result, 0.869058, WITHOUT any warning
> message.
>
> This is why it is a BUG.
>
> By the way, again here we speak as usually about a family
> of bugs, say
>
> NIntegrate[Log[1 + z^2] BesselJ[0, z]^2/z, {z, 0, Infinity}]
> NIntegrate[Log[1 + z^2] BesselJ[2, z]^2/z, {z, 0, Infinity}]
> NIntegrate[Log[1 + z^2] BesselJ[3, z]^2/z, {z, 0, Infinity}]
>
> manifest the same bug (invalid value AND no warning).
>
> Best wishes,
>
> Vladimir Bondarenko
>
> VM and GEMM architect
> Co-founder, CEO, Mathematical Director
>
> http://www.cybertester.com/ Cyber Tester, LLChttp://maple.bug-list.org/ Maple Bugs Encyclopaediahttp://www.CAS-testing.org/ CAS Testing
> > Dimitris- -
>
> - -

I agree partly with you.
It is a buggy performance as regards the no returning
of a warning message.
But as regards the incorrect result I don't believe
that it is a bug.
The default settings of NIntegrate cannot get a correct
numerical estaimation. That's all!
I don't believe that someone wants from a CAS algorithm
its default settings to cover all the possible integrals
that a user can encounter.
If so, who would need the so many options of NIntegrate?!

Dimitris

dimitris

unread,
Jul 30, 2007, 4:19:41 PM7/30/07
to

Hi.
I see a sense of humor that I don't encounter frequently in CAS
community.
Although I think I was clear in my first message I will make one
more attempt to explain myself.

This thread is about Numerical integration.
No Simplify, no Integrate, no (D)Solve and the staff.

Vladimir obviously discovers a bug.
But for me, it is a buggy performance because no message is returned
about the possible error of the result.

But as regards the incorrect result itself I don't believe


that it is a bug.
The default settings of NIntegrate cannot get a correct

numerical estaimation. That's all! No more, no less.

I don't believe that someone wants from a CAS algorithm
its default settings to cover all the possible integrals
that a user can encounter.
If so, who would need the so many options of NIntegrate?!

Dimitris

PS

In[4]:=
\!\(NIntegrate[\(1\/\@x\) BesselJ[0, x], {x, 0, }]\)

>From In[4]:=
\!\(\*
RowBox[{\(NIntegrate::"slwcon
"\), \(\(:\)\(\ \)\), "\<\"Numerical integration
converging too slowly; suspect
one of the following: singularity, value of the integration being
0, \
oscillatory integrand, or insufficient WorkingPrecision. If your
integrand is \
oscillatory try using the option Method->Oscillatory in NIntegrate. \
\\!\\(\\*ButtonBox[\\\"More...\\\", ButtonStyle->\\\"RefGuideLinkText\\
\", \
ButtonFrame->None, ButtonData:>\\\"NIntegrate::slwcon\\\"]\\)\"\>"}]\)

>From In[4]:=
\!\(\*
RowBox[{\(NIntegrate::"ncvb"\), \(\(:\)\(\ \)\), "\<\"NIntegrate
failed
to converge to prescribed accuracy
after \\!\\(7\\) recursive bisections in \\!\\(x\\) near \\!\\(x\
\) = \\!\
\\(1.9939919252733317`*^19\\). \\!\\(\\*ButtonBox[\\\"More...\\\", \
ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \
ButtonData:>\\\"NIntegrate::ncvb\\\"]\\)\"\>"}]\)

Out[4]=
4.70489

Is is a bug the incorrect result?
Think twice!

In[3]:=
NIntegrate[(1/Sqrt[x])*BesselJ[0, x], {x, 0, Infinity}, Method ->
Oscillatory]

Out[3]=
2.092099240131269

dimitris

unread,
Jul 30, 2007, 4:21:12 PM7/30/07
to
> I don't believe that someone wants from a CAS algorithm

I should have said "waits" instead of wants.


dimitris

unread,
Jul 30, 2007, 6:25:05 PM7/30/07
to
On 30 , 06:37, Vladimir Bondarenko <v...@cybertester.com> wrote:
> http://www.cybertester.com/ Cyber Tester, LLChttp://maple.bug-list.org/ Maple Bugs Encyclopaediahttp://www.CAS-testing.org/ CAS Testing

Apart from the performance of NIntegrate iself, has
some interesting issues must be pointed out.

1)
Mma 5.2 (and 6 I guess, in view of Vladimir's original message)

In[3]:=
Integrate[Log[1 + z^2]*(BesselJ[1, z]^2/z), {z, 0, Infinity}]
N[%, 10]

Out[3]=
MeijerG[{{1/2}, {}}, {{0, 0}, {-1}}, 1]/(2*Sqrt[Pi])
Out[4]=
0.8732180258611361020606751916`10.

Maple 10

convert("Integrate[Log[1 + z^2]*(BesselJ[1, z]^2/z), {z, 0,
Infinity}]",FromMma,evaluate);evalf(%,20);

convert("Integrate[Log[1 + z^2]*(BesselJ[1, z]^2/z), {z, 0,
Infinity}]",FromMma,evaluate);evalf(%,20);

1/2
1/2 (2 Pi BesselI(0, 1) BesselK(0, 1)
1/2 / 1/2
+ 2 Pi BesselK(1, 1) BesselI(1, 1)) / Pi
/

0.87321802586113613925

Is would be cool how someone can simplify the MiejerG function
of Mma to the Bessels expression of Maple.

2)How can somebody obtaining in a reasonable timing
a numerical estimation in Maple 10?

evalf(Int(ln(1+z^2)*BesselJ(1,z)^2/z,z = 0 .. infinity));

does not return a result after several minutes.
If i miss something fundamentally of Maple, I apologize.
I would like to see how someone must work here.

3) Although Mma 5.2 is quite good I would like to see
a some workarounds offering better numerical estimation.
For example myself couldn't get something better than

In[16]:=
NIntegrate[Log[1+z^2]*(BesselJ[1,z]^2/z),{z,
0, },MaxRecursion\[Rule]18]//InputForm

>From In[16]:=


\!\(\*
RowBox[{\(NIntegrate::"slwcon
"\), \(\(:\)\(\ \)\), "\<\"Numerical integration
converging too slowly; suspect
one of the following: singularity, value of the integration being
0, \
oscillatory integrand, or insufficient WorkingPrecision. If your
integrand is \
oscillatory try using the option Method->Oscillatory in NIntegrate. \
\\!\\(\\*ButtonBox[\\\"More...\\\", ButtonStyle->\\\"RefGuideLinkText\\
\", \
ButtonFrame->None, ButtonData:>\\\"NIntegrate::slwcon\\\"]\\)\"\>"}]\)

>From In[16]:=


\!\(\*
RowBox[{\(NIntegrate::"ncvb"\), \(\(:\)\(\ \)\), "\<\"NIntegrate
failed
to converge to prescribed accuracy

after \\!\\(19\\) recursive bisections in \\!\\(z\\) near \\!\\(z\
\) = \
\\!\\(35857.55603944016`\\). \\!\\(\\*ButtonBox[\\\"More...\\\", \


ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \
ButtonData:>\\\"NIntegrate::ncvb\\\"]\\)\"\>"}]\)

Out[16]//InputForm=
0.8732193803103058

Dimitris

0 new messages