Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Integrate vs NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89182] Re: [mg89147] Re: [mg89129] Integrate vs NIntegrate
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Wed, 28 May 2008 04:46:27 -0400 (EDT)
  • References: <9489155.1211802216995.JavaMail.root@m08> <op.ubr1yjh52c6ksp@bobbys-imac> <2b8d8f40805261936u2ec81454r1b6ba16be0897662@mail.gmail.com> <200805271114.HAA01380@smc.vnet.net>

I would say that Integrate is correct. Evidence:

In[1]:= q = -2^(-1);

In[2]:= f = Integrate[(1 + x^3)^q, x];

In[3]:= g = Chop[N[D[Normal[f + O[x]^12], x]]]

Out[3]= -0.3125000000000013*x^9 + 0.37500000000000105*x^6 -  
0.5000000000001258*x^3 +
    0.9999999999999998

and, on the other hand:

In[4]:= N[Normal[(1 + x^3)^q + O[x]^10]]
Out[4]= -0.3125*x^9 + 0.375*x^6 - 0.5*x^3 + 1.


Not a proof, of course, but I would bet a fair amount on it being right.

Andrzej Kozlowski


On 27 May 2008, at 20:14, DrMajorBob wrote:

> Because they're completely different. One is an antiderivative in  
> Complex
> variables; the other is a definite integral from 0 to x (so you know  
> that
> it is zero at zero, among other things). Antiderivatives tend to have
> branch cuts, poles, etc., and Mathematica's chosen branch is complex  
> in
> part of your region.
>
> Or... it's entirely possible Mathematica's answer for  
> Integrate[h[x], x]
> is simply WRONG.
>
> Let's check whether it has the correct derivative:
>
> q = -1/2; a = 0; b = 3;
> h[x_] = (1 + x^3)^q;
> f[x_] = Integrate[h[x], x];
> FullSimplify[f'[x] == h[x], a < x < b]
>
> Sqrt[-(1 + x) (-1 + (-1)^(1/3) x)] == (
>  2 (-1)^(1/12) Sqrt[-(-1)^(1/6) ((-1)^(2/3) + x) (1 + x^3)])/(
>  Sqrt[1 - I/Sqrt[3] + (-1 - I/Sqrt[3]) x] Sqrt[
>   3 + I Sqrt[3] + I (3 I + Sqrt[3]) x])
>
> As you see, FullSimplify doesn't think Integrate got a correct  
> result. Or
> at least, it couldn't verify it.
>
> Here's an attempt to provide FullSimplify some adult supervision:
>
>  simple= FullSimplify[ #, a<x<b]&;
>  test= f'[x]== h[x]//simple
>
> Sqrt[(-(1 + x))*(-1 + (-1)^(1/3)*x)] ==
> (2*(-1)^(1/12)*Sqrt[(-(-1)^(1/6))*((-1)^(2/3) + x)*(1 + x^3)])/ 
> (Sqrt[1 -
> I/Sqrt[3] + (-1 - I/Sqrt[3])*x]*Sqrt[3 + I*Sqrt[3] + I*(3*I +  
> Sqrt[3])*x])
>
>  test2 = simple[test /. {(-1)^(1/3) -> -1, (-1)^(2/3) ->
> ComplexExpand[Exp[I*(Pi/3)]], (-1)^(1/6) -> ComplexExpand[Exp[I*(Pi/ 
> 6)]],
> (-1)^(1/12) -> ComplexExpand[Exp[I*(Pi/12)]]}]
>
> 1 + x == (((1/2 + I/2)*(3 - I*Sqrt[3])*Sqrt[(-(2*I + (I +  
> Sqrt[3])*x))*(1
> + x^3)])/Sqrt[3 - I*Sqrt[3] + (-3 - I*Sqrt[3])*x])*Sqrt[3 + I*Sqrt[3]
> + I*(3*I + Sqrt[3])*x]
>
>  test3 = test2 /. (z_)^(r_) :> ComplexExpand[z]^r
>
> 1 + x == (((1/2 + I/2)*(3 - I*Sqrt[3])*Sqrt[(-Sqrt[3])*x - Sqrt[3]*x^4
> + I*(-2 - x - 2*x^3 - x^4)])/Sqrt[3 - 3*x + I*(-Sqrt[3] -
> Sqrt[3]*x)])*Sqrt[3 - 3*x + I*(Sqrt[3] + Sqrt[3]*x)]
>
>  simple[(#1^2 & ) /@ test3]
>
> 2*I + (3*I + Sqrt[3])*x == 0
>
> I don't think Integrate has the right answer.
>
> Bobby
>
> On Mon, 26 May 2008 21:36:31 -0500, Armen Kocharyan
> <armen.kocharyan at gmail.com> wrote:
>
>> Dear Bob,
>>
>> Sorry for the asterisks, it wasn't intentional. I just cut and paste
>> from my
>> notebook.
>>
>> I understand. But why would Mathematica give different results for  
>> the
>> following?
>>
>> Integrate[h[t], {t, 0, x}] and Integrate[h[x], x]
>>
>>
>> Regards,
>> Armen
>>
>> 2008/5/27 DrMajorBob <drmajorbob at att.net>:
>>
>>> The fundamental theorem of calculus frequently does not apply  
>>> when, as
>>> in
>>> your example, Integrate is free to return a Complex-valued function.
>>>
>>> (A better question is why you put in all those extraneous stars to
>>> inhibit
>>> copy/pasting the code.)
>>>
>>> Despite that, here's a slightly different approach where the FTC  
>>> does
>>> apply:
>>>
>>> q = -1/2; a = 0; b = 3;
>>> h[x_] = (1 + x^3)^q;
>>> f[x_] = Integrate[h[t], {t, 0, x}]
>>>
>>> If[x >= -1, (x^3)^(1/3) Hypergeometric2F1[1/3, 1/2, 4/3, -x^3],
>>> Integrate[1/Sqrt[1 + t^3], {t, 0, x}, Assumptions -> x < -1]]
>>>
>>> Res1 = N[f[b] - f[a]]
>>> Res2 = NIntegrate[h[x], {x, a, b}]
>>>
>>> 1.65267
>>>
>>> 1.65267
>>>
>>> Contrast that definition of f with yours:
>>>
>>> Integrate[h[x], x]
>>>
>>> (1/(3^(1/4) Sqrt[1 + x^3]))2 (-1)^(
>>> 1/6) Sqrt[-(-1)^(1/6) ((-1)^(2/3) + x)] Sqrt[
>>> 1 + (-1)^(1/3) x + (-1)^(2/3) x^2]
>>> EllipticF[ArcSin[Sqrt[-(-1)^(5/6) (1 + x)]/3^(1/4)], (-1)^(1/3)]
>>>
>>> If you plot both versions from a to b (use PlotRange->All to be  
>>> sure),
>>> you'll find that your version is complex on part of the range  
>>> (between
>>> 2 and
>>> 3), but mine is real.
>>>
>>> Bobby
>>>
>>>
>>> On Mon, 26 May 2008 05:23:35 -0500, Armen Kocharyan <
>>> armen.kocharyan at gmail.com> wrote:
>>>
>>> *q=-1/2; a=0; b=3;*
>>>> *h[x_]=(1+x^3)^q;*
>>>> *f[x_]=Integrate[h[x],x];*
>>>> *Res1=N[f[b]-f[a]]*
>>>> *Res2=NIntegrate[h[x],{x,a,b}]*
>>>>
>>>
>>>
>>>
>>> --
>>> DrMajorBob at longhorns.com
>>>
>
>
>
> -- 
>
> DrMajorBob at longhorns.com
>



  • Prev by Date: Re: Re: Range of Use of Mathematica
  • Next by Date: Re: No Show
  • Previous by thread: Re: Integrate vs NIntegrate
  • Next by thread: Re: Re: Re: Integrate vs NIntegrate