Results 1 to 5 of 5
Like Tree2Thanks
  • 1 Post By BillSimpson
  • 1 Post By BillSimpson

Math Help - computin multiple integral with ugly - but positive - function (mathematica/matlab)

  1. #1
    Junior Member
    Joined
    Aug 2008
    Posts
    74
    Thanks
    1

    computin multiple integral with ugly - but positive - function (mathematica/matlab)

    hello everyone,

    I'm trying to compute a triple integral in mathematica (with NIntegrate), but it's not giving me a good answer. In fact it sometimes gives me a number close to 22, sometimes (if I increase working presicion) close to 90, etc (I'm actually expecting this integral to be less than 1). And everytime it also says that integral converges too slowly. However the function is positive, so I don't understand why is it so hard to compute. Are there tricks I could use to evaluate the integral precisely, in these cases?

    I tried Monte Carlo method, and it gives me even more random answers...

    Btw, the function does have blow-ups on the edges, but they are of the form 1/\sqrt{x}, which is integrable.

    Just in case someone interested, here's my function:

    NIntegrate[ 2*1/(3!*\[Pi]^2) * r*(2 r*Sin[t]*(r^2 + z1^2 - 2*r*z1*Cos[t]))/((1 + r^2 z1^2 - 2 r z1 Cos[t])*Sqrt[((1 + r^2*Sin[t]^2 - r^2*Cos[t]^2)^2 + 4*r^4*Sin[t]^2*Cos[t]^2)]*Sqrt[1 - z1^2]*(1 - r^2)), {z1, -1, 1}, {r, 0, 1}, {t, 0, \[Pi]}, MaxRecursion -> 50, WorkingPrecision -> 200, PrecisionGoal -> 8]
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Apr 2012
    From
    us
    Posts
    9
    Thanks
    2

    Re: computin multiple integral with ugly - but positive - function (mathematica/matla

    Different regions of your integrand present different challenges to the integrator.

    As a first simple experiment I subdivided the integrand into the interior, the six "faces" and the eight "corners." Some of those regions appear to integrate relatively nicely while others seem to have substantially more trouble. Actually I'm not certain that there might need to be further subdivisions near t=Pi/2.

    Here is what I've been looking at:
    In[1]:= d=1/30;
    f=Simplify[2*1/(3!*π^2)*r*(2 r*Sin[t]*(r^2+z1^2-2*r*z1*Cos[t]))/((1+r^2 z1^2-2 r z1 Cos[t])*
    Sqrt[((1+r^2*Sin[t]^2-r^2*Cos[t]^2)^2+4*r^4*Sin[t]^2*Cos[t]^2)]*Sqrt[1-z1^2]*(1-r^2))]

    Interior

    In[3]:= NIntegrate[f,{z1,-1+d,1-d},{r,0+d,1-d},{t,d Pi,π-d Pi}]

    Faces

    In[4]:= NIntegrate[f,{z1,-1,-1+d},{r,d,1-d},{t,d Pi,π-d Pi}]

    In[5]:= NIntegrate[f,{z1,1-d,1},{r,d,1-d},{t,d Pi,π-d Pi}]

    In[6]:= NIntegrate[f,{z1,-1+d,1-d},{r,0,d},{t,d Pi,π-d Pi}]

    In[7]:= NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,d Pi,π-d Pi}]

    In[8]:= NIntegrate[f,{z1,-1+d,1-d},{r,d,1-d},{t,0,d Pi}]

    In[9]:= NIntegrate[f,{z1,1-d,1},{r,d,1-d},{t,π-d Pi,Pi}]

    Corners

    In[10]:= NIntegrate[f,{z1,-1,-1+d},{r,0,d},{t,0,d Pi}]

    In[11]:= NIntegrate[f,{z1,-1,-1+d},{r,0,d},{t,Pi-d Pi,Pi}]

    In[12]:= NIntegrate[f,{z1,-1,-1+d},{r,1-d,1},{t,0,d Pi}]

    In[13]:= NIntegrate[f,{z1,-1,-1+d},{r,1-d,1},{t,Pi-d Pi,Pi}]

    In[14]:= NIntegrate[f,{z1,1-d,1},{r,0,d},{t,0,d Pi}]

    In[15]:= NIntegrate[f,{z1,1-d,1},{r,0,d},{t,Pi-d Pi,Pi}]

    In[16]:= NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,0,d Pi}]

    In[17]:= NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,Pi-d Pi,Pi}]

    Inspect the denominator of the simplified expression carefully and look for regions where the denominator will go to zero. I believe those will tend to pose the greatest challenges to the integrator.

    As you increase the PrecisionGoal this will further expose which of these regions have increased problems.
    Last edited by BillSimpson; July 9th 2012 at 09:33 PM.
    Thanks from choovuck
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Aug 2008
    Posts
    74
    Thanks
    1

    Re: computin multiple integral with ugly - but positive - function (mathematica/matla

    Good idea. I will play with each of the regions as you suggested. After giving it a try it looks like the integrand indeed might have some unintegrable places there...

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Apr 2012
    From
    us
    Posts
    9
    Thanks
    2

    Re: computin multiple integral with ugly - but positive - function (mathematica/matla

    I apologize for one error that I didn't notice until it was too late to edit and correct this.

    When I scraped and pasted between Mathematica some of the \[Pi] turned into n and others remained as Pi.
    Hopefully this has corrected all those errors, but check this carefully to make certain that none remain.

    d=1/30;
    f=Simplify[2*1/(3!*Pi^2)*r*(2 r*Sin[t]*(r^2+z1^2-2*r*z1*Cos[t]))/((1+r^2 z1^2-2 r z1 Cos[t])*
    Sqrt[((1+r^2*Sin[t]^2-r^2*Cos[t]^2)^2+4*r^4*Sin[t]^2*Cos[t]^2)]*Sqrt[1-z1^2]*(1-r^2))]

    Interior

    NIntegrate[f,{z1,-1+d,1-d},{r,d,1-d},{t,d Pi,Pi-d Pi}]

    Faces

    NIntegrate[f,{z1,-1,-1+d},{r,d,1-d},{t,d Pi,Pi-d Pi}]

    NIntegrate[f,{z1,1-d,1},{r,d,1-d},{t,d Pi,Pi-d Pi}]

    NIntegrate[f,{z1,-1+d,1-d},{r,0,d},{t,d Pi,Pi-d Pi}]

    NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,d Pi,Pi-d Pi}]

    NIntegrate[f,{z1,-1+d,1-d},{r,d,1-d},{t,0,d Pi}]

    NIntegrate[f,{z1,1-d,1},{r,d,1-d},{t,Pi-d Pi,Pi}]

    Corners

    NIntegrate[f,{z1,-1,-1+d},{r,0,d},{t,0,d Pi}]

    NIntegrate[f,{z1,-1,-1+d},{r,0,d},{t,Pi-d Pi,Pi}]

    NIntegrate[f,{z1,-1,-1+d},{r,1-d,1},{t,0,d Pi}]

    NIntegrate[f,{z1,-1,-1+d},{r,1-d,1},{t,Pi-d Pi,Pi}]

    NIntegrate[f,{z1,1-d,1},{r,0,d},{t,0,d Pi}]

    NIntegrate[f,{z1,1-d,1},{r,0,d},{t,Pi-d Pi,Pi}]

    NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,0,d Pi}]

    NIntegrate[f,{z1,1-d,1},{r,1-d,1},{t,Pi-d Pi,Pi}]

    If I haven't made another mistake then you can use Reduce on your denominator==0&&your range limitations on the variables and I believe you will find that the denominator will be zero when r==1 or when z1==1. That might help focus your attention on the regions where integration may be having more problems.
    Last edited by BillSimpson; July 10th 2012 at 12:12 PM.
    Thanks from choovuck
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Aug 2008
    Posts
    74
    Thanks
    1

    Re: computin multiple integral with ugly - but positive - function (mathematica/matla

    yep, I figured the Pi thing, no worries. thanks again.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: March 22nd 2010, 09:14 AM
  2. Mathematica: Multiple plots
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 12th 2010, 12:25 PM
  3. multiple regression with constraint on positive parameters
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: November 10th 2009, 01:34 AM
  4. Ugly integral
    Posted in the Calculus Forum
    Replies: 1
    Last Post: February 11th 2009, 07:29 AM
  5. Multiple array generation in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 29th 2009, 02:01 PM

Search Tags


/mathhelpforum @mathhelpforum