Mathematica : Numerical Integration

In summary, the conversation discusses the difficulty of numerically integrating a function with 5 variables and a small section of phase space. Possible solutions such as making a transformation and simplifying the integrand are suggested to improve accuracy. The use of Monte Carlo integration is also discussed, but it is heavily dependent on the maximum number of points allowed. The potential for the integral to be divergent is raised and the possibility of simplifying the problem is mentioned.
  • #1
Hepth
Gold Member
464
40
So I have to numerically integrate a function that is quite difficult. I could post it, but its long.
Regardless, there are 5 variables I am integrating over. The first is independent. The next 4 are subsequently dependent on the integration limits of the previous. Not a big deal.

something like

Integrate[F[x,y,z,t],{x,XCUT, 1},{y,0,Sqrt[1-x^2]},{z,0,1-x-y},{t,-1,1}]

but more.

Now, my problem comes in that XCUT is very close to 1. So say 0.977. That means that y only varies from 0 to something small, and z is also small. So its a very small slice of phase space that I'm integrating over.

What happens is my basic numerical integration outputs something like :

NIntegrate obtained 3.02466*10^-6 and 3.08509*10^-6 for the integral and error estimates.

So the error is appx the integral.

So what else can I do? Monte carlo seems to give me an answer without error, but seems to be heavily dependent on the maximum number of points I allow it to use.

Is there a way to do a HIGHLY ACCURATE numerical integration, where some of the limits might be close to poles. Time is not an issue, I can throw it on the cluster.

Pumping up WorkingPrecision doesn't seem to help much. Same with max recursion.
 
Physics news on Phys.org
  • #2
What happens with

Integrate[F[x,y,z,t],{x,977/1000, 1},{y,0,Sqrt[1-x^2]},{z,0,1-x-y},{t,-1,1}]

and there are absolutely no decimal points anywhere in the definition of F[]?
 
  • #3
Hepth said:
So I have to numerically integrate a function that is quite difficult. I could post it, but its long.
Regardless, there are 5 variables I am integrating over. The first is independent. The next 4 are subsequently dependent on the integration limits of the previous. Not a big deal.

something like

Integrate[F[x,y,z,t],{x,XCUT, 1},{y,0,Sqrt[1-x^2]},{z,0,1-x-y},{t,-1,1}]

but more.

Now, my problem comes in that XCUT is very close to 1. So say 0.977. That means that y only varies from 0 to something small, and z is also small. So its a very small slice of phase space that I'm integrating over.
Beyond specifying everything that you see as exact numbers, one other thing you can try is to make a transformation [itex]x= 1 + \chi[/itex] everywhere.
 
  • #4
Bill Simpson said:
What happens with

Integrate[F[x,y,z,t],{x,977/1000, 1},{y,0,Sqrt[1-x^2]},{z,0,1-x-y},{t,-1,1}]

and there are absolutely no decimal points anywhere in the definition of F[]?

I made sure not to have ANY decimals. The integral itself is already scaled with only one input parameter that I put in as "2/5".

Same thing.

I'll attach a notebook with one of my integrals.


DaleSpam said:
Beyond specifying everything that you see as exact numbers, one other thing you can try is to make a transformation [itex]x= 1 + \chi[/itex] everywhere.

The thing is there are no numbers really. Its basically a small section of phase space that I'm integrating over, and I wonder if its just too small, or what to change to get a consistent answer.
 

Attachments

  • integrate_hepth.nb
    16 KB · Views: 538
Last edited:
  • #5
I'm starting to think the integral is divergent, but then monte carlo integration shouldn't be getting smaller the larger the number of points I give it...

Maybe its actually Zero, but in some roundabout, definite-integral way.

EDIT: few minutes, I'll get the actual integrand.
EDIT: the above notebook has been updated
 
Last edited:
  • #6
In your current notebook your integrand has a large repeated subexpression.

If you look at this, and my scrape-n-paste hasn't failed,

In[1]:= FN /. (2 S2^2+T1 (S1+T1) (-1+S1+T1+U2) - S2 (S1 (2+T1-U2) + 2 (-1+U2) + T1 (2+T1+U2)) - 2 Sqrt[S2 (-1+S1-S2+T1) (-S2+S1*T1) (S2 + S1 (-1+U2) + (-1+U2) (-1+T1+U2))] \[Zeta]2)/(-4 S2 + (S1+T1)^2) -> V1

Out[1]= -(((S2*(-1+T1) - T1*(-1+S1+T1))*(-(S1*(-1+T1+U2-V1)) + (-U2+V1)*(1-T1-U2+V1)))/ ((29/25-T1-U2+V1)^2*Sqrt[(-S1^2 - (-1+S2)^2 + 2*S1*(1+S2))*(-1+\[Zeta]2^2)]))

The numerator is a quadratic in that big subexpression V1.

I'm thinking you might be able to get the numerator into a form a+(b+V1)^2 for some a and b and this might make it substantially more compact and easier to understand, and perhaps even see whether the integral is zero or not. I'm even questioning whether many of the S, T and U terms might get absorbed in that more compact result. Unfortunately I have not been able to coax Mathematica into doing that for me yet.

Here is one attempt at the numerator

-((S2*(-1+T1) - T1*(-1+S1+T1))^2*(1+S1-T1-2*U2)^2)/4 + (S2*(-1+T1) - T1*(-1+S1+T1))*(S1-U2)*(-1+T1+U2)
+(((S2*(-1+T1) - T1*(-1+S1+T1))*(-1-S1+T1+2*U2))/2 + V1)^2

but the S,T and U outside the squared term didn't mostly disappear inside the squared term as I had hoped they might. Perhaps I've made a mistake or perhaps there is another way to reorganize this to compact it further.

Sometimes complicated integrals can be turned into a sum of substantially smaller integrals, sometimes using Apart to split apart the numerator. There have been examples where this resulted in a vast number of simpler integrals, most of which were able to be integrated exactly, not using NIntegrate, but I'm not sure whether your denominator would allow this much enhancement.
 
Last edited:
  • #7
Actually there was a "T2" that got replaced in terms of the {S1,S2,T1,U2,zeta}, as it and zeta are interchangeable. I think I can actually integrate out the zeta and just get a factor of "pi" overall, for some of the terms (The ones odd in "T2").

I'll try and clean it up some. So does mathematica's numerical integration care how messy or clean the integral is? I thought it wouldn't matter since its getting evaluated at certain points, and the algebraic form doesn't matter.
 
  • #8
When you are doing more additions and subtractions and divisions of low precision numbers every one of those operations is contributing to the overall error of the result.

Since you were subtracting low precision values that were close to each other I was actually thinking you were using Integrate, as you explicitly showed in your very first post in this thread, and sidestep NIntegrate, which deals in nothing but approximate values even after you substituted exact rational numbers as I suggested. That NIntegrate instantly threw away all the exact parameters I recommended and began fiddling with floating point and accumulated error.

If you know more about the problem than the contents of your notebook then I would hope the problem might be simplified to the point where you could get good accurate answers quickly. Try to get rid of the redundancy in the subexpressions. That might help you and Mathematica see that the problem can be simplified even further.
 
  • #9
If you go to the help entry for Integrate (and NIntegrate...), the meaning of a multiple
integral:

NIntegrate[f[x,y],{x,xmin,xmax},{y,ymin,ymax}]
is
[tex]
\int_{x_\mathrm{min}}^{x_\mathrm{max}}{dx \, \int_{y_\mathrm{min}}^{y_\mathrm{max}}{dy \, f(x,y)}}
[/tex]
i.e. the order of the integrations is reversed! Make sure you write the order of the integrands in the Mathematica command the way you want it performed.
 

What is numerical integration in Mathematica?

Numerical integration in Mathematica is a method for approximating the value of a definite integral using numerical techniques. This is useful when the integral cannot be solved analytically.

How do I perform numerical integration in Mathematica?

To perform numerical integration in Mathematica, you can use the function NIntegrate. This function takes in the integrand, the limits of integration, and any other necessary parameters and returns an approximate numerical value for the integral.

What are the different types of numerical integration methods in Mathematica?

There are several different numerical integration methods available in Mathematica, including the Trapezoidal Rule, Simpson's Rule, and Gaussian Quadrature. Each method has its own strengths and limitations, and the best method to use will depend on the specific integral being evaluated.

Can I specify the accuracy or precision of the numerical integration in Mathematica?

Yes, you can specify the desired accuracy and precision of the numerical integration in Mathematica using the options AccuracyGoal and PrecisionGoal. These options allow you to control the level of precision in the final result.

Is there a way to check the accuracy of the numerical integration in Mathematica?

Yes, you can use the option WorkingPrecision to increase the precision of the numerical integration and then compare the results with a known analytical solution, if available. You can also use the option PrecisionGoal to set a specific goal for the precision of the result.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
58
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
227
  • MATLAB, Maple, Mathematica, LaTeX
Replies
27
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
140
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
Back
Top