       Re: Bug? Analytical integration of cosines gets the sign wrong

• To: mathgroup at smc.vnet.net
• Subject: [mg107495] Re: Bug? Analytical integration of cosines gets the sign wrong
• From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
• Date: Sun, 14 Feb 2010 08:24:46 -0500 (EST)
• References: <hkeb9k\$b5\$1@smc.vnet.net> <201002100835.DAA21213@smc.vnet.net> <hl0lff\$r9k\$1@smc.vnet.net>

```Plot[f[x] // Evaluate, {x, Pi, 2 Pi}, PlotRange -> All]

would plot much quicker because it evaluates the Integrate once and for all
inside the Plot.

Alternatively, omit the // Evaluate, and use = rather than := in the
definition of f[x], which evaluates the Integrate once and for all in the
definition of f[x].

--
Stephen Luttrell
West Malvern, UK

"Louis Talman" <talmanl at gmail.com> wrote in message
news:hl0lff\$r9k\$1 at smc.vnet.net...
> Actually, something very strange---even stranger than has already been
> pointed out---is going on.
>
> Try, in version 7 of Mathematica (be prepared to wait a little while):
>
> --------------------
> f[x_] := Integrate[Cos[ t ] Cos[ 2 t ] Cos[ 4 t ], { t, Pi, x }]
>
> Plot[ f[x], {x, Pi, 2 Pi}, PlotRange -> All ]
> --------------------
>
>
>
> Then compare the resulting plot with the one obtained from
>
> --------------------
> F[x_] = Integrate[ Cos[ x ] Cos[ 2 x ] Cos[ 4 x ], x]
>
> Plot[ F[x] - F[Pi], { x, Pi, 2 Pi}, PlotRange -> All ]
> --------------------
>
> On my PPC iMac running OS X, v10.5.8, the first plot is the reflection
> of the second plot about the x-axis.
>
>
> On Feb 10, 2010, at 1:35 AM, WetBlanket wrote:
>
>> On Feb 4, 5:33 am, K <kgs... at googlemail.com> wrote:
>>> Hello everyone,
>>>
>>> the analytical integration in Mathematica 7.01.0 on Linux x86 (64bit)
>>>
>>> faultyInt =
>>> Integrate[Cos[ph]*1/Pi*Cos[4*ph]*Cos[2*ph], {ph, Pi, 3/2*Pi}]
>>>
>>> gives as result:
>>>
>>> 19/(105 \[Pi])
>>>
>>> which is as a decimal number
>>>
>>> N[faultyInt]
>>>
>>> 0.0575989
>>>
>>> The numerical integration
>>>
>>> NIntegrate[Cos[ph]*1/Pi*Cos[4*ph]*Cos[2*ph],{ph,Pi,3/2*Pi}]
>>>
>>> gives
>>>
>>> -0.0575989
>>>
>>> which I believe is correct by judging from the plot
>>>
>>> Plot[Cos[ph]*1/Pi*Cos[4*ph]*Cos[2*ph], {ph, Pi, 3/2*Pi},
>>> PlotRange -> {-1/Pi, 1/Pi}]
>>>
>>> and because the quadgk function in another system gives the same
>>> negative result.  Could anyone try this at home (or work, rather)
>>> and confirm or disprove it?
>>> Thanks,
>>> K.
>> If One substitutes the sequence, {1.9, 1.99, 1.999, ... 2.0}
>> Mathematica gets the correct answer for as long as I tried except, of
>> course for 2.0.
>>
>
>

```

• Prev by Date: Re: When can Mathematica have a decent Find dialogue?
• Next by Date: Re: When can Mathematica have a decent Find dialogue?
• Previous by thread: Re: Re: Bug? Analytical integration of cosines gets the sign wrong
• Next by thread: Localize Pattern variables