# Running a matrix of integrals in parallel

• Mathematica
Gold Member

## Main Question or Discussion Point

Hi PF!

I am trying to computer a matrix of integrals. Think of it something like this:

Code:
Table[Integrate[x^(i*j), {x, 0, 1}], {i, 0, 5}, {j, 0, 5}]
I have 16 cores, and would like to have each core handle a specified amount of integrals. Anyone know how to do this?

Thanks so much!

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
DrClaude
Mentor
• joshmccraney
Gold Member
Thanks! I checked it out and evidently the function ParallelTable is appropriate here. Looks like this:

Code:
ParallelTable[Integrate[x^(i*j), {x, 0, 1}], {i, 0, 5}, {j, 0, 5}]
To your knowledge, is this the most efficient way to parallelize? Seems to use all 16 cores too.

DrClaude
Mentor
I don't program much in Mathematica, but I have used other people's programs. Using ParallelTable in your case should be the fastest option, but it is possible that Parallelize[Table[]] would result in the same (I have stopped trying to figure out how Mathematica deals with things internally; it is quite opaque).

Gold Member
I don't program much in Mathematica, but I have used other people's programs. Using ParallelTable in your case should be the fastest option, but it is possible that Parallelize[Table[]] would result in the same (I have stopped trying to figure out how Mathematica deals with things internally; it is quite opaque).
This actually didn't work, shockingly. Agreed, I don't know what is going on under the Mathematica hood.