Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Integrate vs NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89147] Re: [mg89129] Integrate vs NIntegrate
  • From: DrMajorBob <drmajorbob at att.net>
  • Date: Tue, 27 May 2008 07:14:05 -0400 (EDT)
  • References: <9489155.1211802216995.JavaMail.root@m08> <op.ubr1yjh52c6ksp@bobbys-imac> <2b8d8f40805261936u2ec81454r1b6ba16be0897662@mail.gmail.com>
  • Reply-to: drmajorbob at longhorns.com

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: No Show
  • Next by Date: Re: Bug in Mathematica or my mistake?
  • Previous by thread: Re: Integrate vs NIntegrate
  • Next by thread: Re: Re: Integrate vs NIntegrate