0
votes

Using Mathematica I need to evaluate the integral of a function. Since it is taking the program too much to compute it, would it be possible to use parallel computation to shorten the time needed? If so, how can I do it?

I uploaded a picture of the integrand function:

I need to integrate it with respect to (x3, y3, x, y) all of them ranging in a certain interval (x3 and y3 from 0 to 1) (x and y from 0 to 100). The parameters (a,b,c...,o) are preventing the NIntegrate function to work. Any suggestions?

I need to integrate it with respect to (x3, y3, x, y) all of them ranging  in a certain interval (x3 and y3 from 0 to 1) (x and y from 0 to 100). The parameters (a,b,c...,o) are preventing the NIntegrate function to work. Any suggestions?

1

1 Answers

2
votes

If you evaluate this

expr=E^((-(x-y)^4-(x3-y3)^4)/10^4)*
  (f x+e x^2+(m+n x)x3-f y-e y^2-(m+n y)y3)*
   ((378(x-y)^2(f x+e x^2+(m+n x)x3-f y-e y^2-(m+n y)y3))/
    (Pi(1/40+Sqrt[((x-y)^2+(x3-y3)^2)^3]))+
   (378(x-y)(x3-y3)(h x+g x^2+(o+p x)x3-h y-g y^2-(o+p y)y3))/
    (Pi(1/40+Sqrt[((x-y)^2+(x3-y3)^2)^3])))+
  (h x+g x^2+(o+p x)x3-h y-g y^2-(o +p y) y3)*
   ((378(x-y)(x3-y3)(f x+e x^2+(m+n x)x3-f y-e y^2-(m+n y)y3))/
    (Pi(1/40+Sqrt[((x-y)^2+(x3-y3)^2)^3]))+
   (378 (x3 - y3)^2 (h x + g x^2 + (o + p x)x3-h y-g y^2-(o+p y)y3))/
    (Pi(1/40+Sqrt[((x-y)^2+(x3-y3)^2)^3])));
list=List @@ Expand[expr]

then you will get a list of 484 expressions, each very similar in form to this

(378*f*h*x^3*x3)/(Pi*(1/40+Sqrt[(x^2+x3^2-2*x*y+y^2-2*x3*y3+y3^2)^3]))

Notice that you can then use NIntegrate in this way

f*h*NIntegrate[(378*x^3*x3)/(Pi*(1/40+Sqrt[(x^2+x3^2-2*x*y+y^2-2*x3*y3+y3^2)^3])),
  {x,0,100},{y,0,100},{x3,0,1},{y3,0,1}]

but it gives warnings and errors about the convergence and accuracy, almost certainly due to your fractional powers in the denominator.

If you can find a way to pull out the scalar multipliers which are independent of x,y,x3,y3 and then perform that integration without warnings and errors and get an accurate result which isn't infinity then you could perhaps perform these integrals in parallel and total the results.

Some of the integrands are scalar multiples of others and if you combine similar integrands then you can reduce this down to 300 unique integrands.

I doubt this is going to lead to an acceptable solution for you.

Please check all this very carefully to make certain that no mistakes have been made.

EDIT

Since the variables that are independent of the integration appear to be easily separated from the dependent variables in the problem posed above, I think this will allow parallel NIntegrate

independentvars[z_] := (z/(z//.{e->1, f->1, g->1, h->1, m->1, n->1, o->1, p->1}))*
  NIntegrate[(z//.{e->1, f->1, g->1, h->1, m->1, n->1, o->1, p->1}),
    {x, 0, 100}, {y, 0, 100}, {x3, 0, 1}, {y3, 0, 1}]

Total[ParallelMap[independentvars, list]]

As I mentioned previously, the fractional powers in the denominator result in a flood of warnings and errors about convergence failing.

You can test this with the following much simpler example

expr = f x + f g x3 + o^2 x x3;
list = List @@ Expand[expr];
Total[ParallelMap[independentvars, list]]

which instantly returns

500000. f + 5000. f g + 250000. o^2

This is a very primitive method of pulling independent symbolic variables outside an NIntegrate. This gives absolutely no warning if one of the integrands is not in a form where this primitive attempt at extraction is not appropriate or fails.

There may be a far better method that someone else has written out there somewhere. If someone could show a far better method of doing this then I would appreciate it.

It might be nice if Wolfram would consider incorporating something like this into NIntegrate itself.