Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function in the following form:

function[...] := With[
    anotherfunction[i, j, ...],
    {i, ...},
    {j, ...},

If I'd like to replace Table with ParallelTable, do I need to put DistributeDefinitions["Global`"] somewhere? If yes, where? (Before With, before ParallelTable, or before calling function?)

anotherfunction is defined globally, and uses other global variables.

share|improve this question
I added the backtick. Click the edit link and see the source on how to do it (you need to surround the code with $n+1$ backticks if you want to include $n$ backticks). – Szabolcs Dec 20 '13 at 18:07
up vote 5 down vote accepted

ParallelTable will automatically distribute the definitions of symbols used in the body of the table, as well as any dependencies, in version 8 and later. It is not necessary to use DistributeDefinitions with ParallelTable in these versions.

Note that ParallelEvaluate does not automatically distribute definitions like Parallelize, ParallelTable, ParallelMap, ParallelDo, etc. do. You do need to use DistributeDefinitions if you rely on ParallelEvaluate, however, you do not need to distribute the definitions of all symbols. Just distribute the symbol that you are actually using, anotherfunction in this case. DistributeDefinitions is smart enough to auto-distribute all the dependencies as well (unless you do something unusual such as converting strings to symbol names).

share|improve this answer
+1. Also note from the documentation: "DistributeDefinitions applies itself recursively to any symbols appearing in the definitions of the symbols s_i." – Andreas Lauschke Dec 20 '13 at 21:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.