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

Integrate 'learns'?

2 views
Skip to first unread message

Tony Harker

unread,
Jan 7, 2010, 2:28:04 AM1/7/10
to

If I open a clean notebook in Version 7.0 for Microsoft Windows (32-bit)
and enter
Integrate[x/(3 Sin[x]),{x,\[Pi]/4,\[Pi]/2}]
the result (after a warning message) is
(8*Catalan - I*Pi^2 + Pi*(-Log[1 - (-1)^(1/4)] + Log[1 + (-1)^(1/4)]) -
(4*I)*(PolyLog[2, -(-1)^(1/4)] - PolyLog[2, (-1)^(1/4)]))/12
and if I then repeat the command I get no error and
(5*Catalan)/6 - ((23*I)/288)*Pi^2 + (Pi*ArcTanh[(-1)^(1/4)])/6 +
((2*I)/3)*PolyLog[2, (-1)^(1/4)]
which seems to be Mathematica's final answer.

I am happy that the results are equivalent, but puzzled about what has
been saved, and where, to generate this difference. Did Mathematica ask the
audience or phone a friend? Can anyone enlighten me?

Tony Harker


Daniel Lichtblau

unread,
Jan 8, 2010, 4:16:20 AM1/8/10
to
> audience or phone a friend?[...]

That's exactly right. Sometimes it also uses the "remove two wrong
answers" option.


> [...] Can anyone enlighten me?
> Tony Harker

Okay, actually Integrate and functions it uses (e.g. Simplify and Limit)
can make use of partial results cached along the way, in beating out
time constraints in later invocations. This is sort of hinted at but
perhaps not stated outright, in the materials at the URL below.

http://library.wolfram.com/infocenter/Conferences/5832/

The upshot is that results can change with further calls. I believe this
has come up on this group in past, but my searching capabilities have
not sufficed to locate relevant prior threads.

I am not seeing the behavior you describe on my machine, by the way.
Versions 7.0.0, 7.0.1, and development all give me the second result and
no message, each time I run the example. I may try it on my machine at
home to see if the platform change makes a difference.


Daniel Lichtblau
Wolfram Research


Tony Harker

unread,
Jan 8, 2010, 4:16:41 AM1/8/10
to
Many thanks, Daniel and Bob. I, too, thought this must have come up before
but failed to locate relevant threads. What you say about not seeing my
first-described behaviour is consistent with what Szabolcs Horv=E1t told me:
"I get the first result you cite only when the system is under load (and
also got it when running the computation right after reboot). I think
people with fast computers won't get it at all." Sounds as if it's time for
me to upgrade my hardware!

Tony

]-> -----Original Message-----
]-> From: Daniel Lichtblau [mailto:da...@wolfram.com]
]-> Sent: 07 January 2010 19:36
]-> To: Tony Harker
]-> Cc: math...@smc.vnet.net
]-> Subject: Re: Integrate 'learns'?
]->
]-> Tony Harker wrote:
]-> > If I open a clean notebook in Version 7.0 for Microsoft Windows
]-> > (32-bit) and enter
]-> > Integrate[x/(3 Sin[x]),{x,\[Pi]/4,\[Pi]/2}]
]-> > the result (after a warning message) is
]-> > (8*Catalan - I*Pi^2 + Pi*(-Log[1 - (-1)^(1/4)] + Log[1 +
]-> > (-1)^(1/4)]) - (4*I)*(PolyLog[2, -(-1)^(1/4)] -
]-> PolyLog[2, (-1)^(1/4)]))/12
]-> > and if I then repeat the command I get no error and
]-> > (5*Catalan)/6 - ((23*I)/288)*Pi^2 +
]-> (Pi*ArcTanh[(-1)^(1/4)])/6 +
]-> > ((2*I)/3)*PolyLog[2, (-1)^(1/4)]
]-> > which seems to be Mathematica's final answer.
]-> >
]-> > I am happy that the results are equivalent, but puzzled
]-> about what
]-> > has been saved, and where, to generate this difference. Did
]-> > Mathematica ask the audience or phone a friend?[...]
]->
]-> That's exactly right. Sometimes it also uses the "remove
]-> two wrong answers" option.
]->
]->
]-> > [...] Can anyone enlighten me?
]-> > Tony Harker
]->
]-> Okay, actually Integrate and functions it uses (e.g.
]-> Simplify and Limit)
]-> can make use of partial results cached along the way, in
]-> beating out
]-> time constraints in later invocations. This is sort of
]-> hinted at but
]-> perhaps not stated outright, in the materials at the URL below.
]->
]-> http://library.wolfram.com/infocenter/Conferences/5832/
]->
]-> The upshot is that results can change with further calls. I
]-> believe this
]-> has come up on this group in past, but my searching
]-> capabilities have
]-> not sufficed to locate relevant prior threads.
]->
]-> I am not seeing the behavior you describe on my machine, by
]-> the way.
]-> Versions 7.0.0, 7.0.1, and development all give me the
]-> second result and
]-> no message, each time I run the example. I may try it on my
]-> machine at
]-> home to see if the platform change makes a difference.
]->
]->
]-> Daniel Lichtblau
]-> Wolfram Research
]->
]->


Bill Rowe

unread,
Jan 8, 2010, 4:17:58 AM1/8/10
to
On 1/7/10 at 2:28 AM, a.ha...@ucl.ac.uk (Tony Harker) wrote:

>If I open a clean notebook in Version 7.0 for Microsoft Windows

>(32-bit)
>and enter Integrate[x/(3 Sin[x]),{x,\[Pi]/4,\[Pi]/2}] the
>result (after a
>warning message) is (8*Catalan - I*Pi^2 + Pi*(-Log[1 - (-1)^(1/4)] +
>Log[1 + (-1)^(1/4)]) -
>(4*I)*(PolyLog[2, -(-1)^(1/4)] - PolyLog[2, (-1)^(1/4)]))/12
>and if I then repeat the command I get no error and (5*Catalan)/6 -


>((23*I)/288)*Pi^2 + (Pi*ArcTanh[(-1)^(1/4)])/6 +
>((2*I)/3)*PolyLog[2, (-1)^(1/4)]

>which seems to be Mathematica's final answer.

>I am happy that the results are equivalent, but puzzled about what has
>been saved, and where, to generate this difference. Did Mathematica ask
>the audience or phone a friend? Can anyone enlighten me?

Using:

In[2]:= $Version

Out[2]= 7.0 for Mac OS X x86 (64-bit) (February 19, 2009)

with a fresh session I get the second result with no warning message.

I believe Integrate like several other built-in functions caches
intermediate computations. The second time the same code is
executed, this cache of intermediate results are available. As a
consequence, the time to get the second result will be shorter.
And in this case have a different form.

You didn't state what the warning message said. My guess is that
if you were to change some of the options for Integrate, you
would get the second result with no warning message the first
time you executed the code. But since I don't get the warning
message on my system, I've no way to determine if this is really
the case or what options should be changed.


Bob Hanlon

unread,
Jan 8, 2010, 4:18:52 AM1/8/10
to

I get the "final answer" directly

$Version

7.0 for Mac OS X x86 (64-bit) (February 19, 2009)

Integrate[x/(3 Sin[x]), {x, Pi/4, Pi/2}]

(5*Catalan)/6 +
(2*I*PolyLog[2, (-1)^(1/4)])/3 -
(23*I*Pi^2)/288 + (1/6)*Pi*
ArcTanh[(-1)^(1/4)]

Perhaps in doing some amount of internal simplification it applies a time constraint. On your second pass it has some cached intermediate result that enables the simplication to progress further within the time constraint.


Bob Hanlon

---- Tony Harker <a.ha...@ucl.ac.uk> wrote:

=============

If I open a clean notebook in Version 7.0 for Microsoft Windows (32-bit)
and enter
Integrate[x/(3 Sin[x]),{x,\[Pi]/4,\[Pi]/2}]
the result (after a warning message) is
(8*Catalan - I*Pi^2 + Pi*(-Log[1 - (-1)^(1/4)] + Log[1 + (-1)^(1/4)]) -
(4*I)*(PolyLog[2, -(-1)^(1/4)] - PolyLog[2, (-1)^(1/4)]))/12
and if I then repeat the command I get no error and
(5*Catalan)/6 - ((23*I)/288)*Pi^2 + (Pi*ArcTanh[(-1)^(1/4)])/6 +
((2*I)/3)*PolyLog[2, (-1)^(1/4)]
which seems to be Mathematica's final answer.

I am happy that the results are equivalent, but puzzled about what has
been saved, and where, to generate this difference. Did Mathematica ask the
audience or phone a friend? Can anyone enlighten me?

Tony Harker

Szabolcs Horvát

unread,
Jan 8, 2010, 4:19:03 AM1/8/10
to

I believe that this is because intermediate results are cached (see
ClearSystemCache[]) and because some computations are time constrained
(i.e. some transformations are tried only for a limited time). Caching
results speeds up computations, and thus may influence the result.
Notice that the second evaluation is also faster.

0 new messages