4
$\begingroup$

The following code makes mathematica print "ParallelTable::nopar1: [...] cannot be parallelized; proceeding with sequential evaluation."

(*Exit[]*)
Subscript[r, 1] = Abs[x + y I];
Subscript[r, 2] = Abs[x + y I - a];
plots = ParallelTable[
   ContourPlot[{Abs[Subscript[r, 1]]/Abs[Subscript[r, 2]] == 
        Subscript[c, 1], 
       Subscript[c, 2] == 
        Abs[Subscript[r, 2]] - Abs[Subscript[r, 1]]} /. a -> 5 // 
     Evaluate, {x, -6, 6}, {y, -6, 6}, 
    FrameTicks -> {Range[-6, 6, 1], Range[-6, 6, 1], None, 
      None}], {Subscript[c, 1], 0, 2, 0.1}, {Subscript[c, 2], -2, 2, 
    0.2}];
Animate[plots[[i]][[j]], {i, 1, Length[plots], 1}, {j, 1, 
  Length[plots[[1]]], 1}]

Why does this happen even when the expression in ParallelTable can be easily evaluated for any values of $c_1$ and $c_2$ ?

Note: "Right Click> convert to StandardForm" will make the subscripts readable.

$\endgroup$
1
  • $\begingroup$ This works r1 = Abs[x + y I]; r2 = Abs[x + y I - a]; plots = ParallelTable[ ContourPlot[{Abs[r1]/Abs[r2] == c1, c2 == Abs[r2] - Abs[r1]} /. a -> 5 // Evaluate, {x, -6, 6}, {y, -6, 6}, FrameTicks -> {Range[-6, 6, 1], Range[-6, 6, 1], None, None}], {c1, 0, 2, 0.1}, {c2, -2, 2, 0.2}]; $\endgroup$
    – chris
    Commented Nov 16, 2012 at 9:13

1 Answer 1

7
$\begingroup$

It seems Mathematica does not like subscript variables for ParallelTable So if you define

r1 = Abs[x + y I];
r2 = Abs[x + y I - a];

then

plots = ParallelTable[
   ContourPlot[{Abs[r1]/Abs[r2] == c1, c2 == Abs[r2] - Abs[r1]} /. 
      a -> 5 // Evaluate, {x, -6, 6}, {y, -6, 6}, 
    FrameTicks -> {Range[-6, 6, 1], Range[-6, 6, 1], None, None}, 
    ContourStyle ->{{ColorData[10][c1*5]}, 
    Directive[Dashed, ColorData[10][(c2 + 2)*2.5]]}], {c1, 0, 2, 0.1}, {c2, -2, 2,
     0.2}];

produces

plots // Flatten // Show

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ Thanks, that seems to work. Is there any real reason why mathematica fails to parallelize when there are subscripts? $\endgroup$
    – Navin
    Commented Nov 16, 2012 at 14:21
  • 1
    $\begingroup$ @Navin this I don't know. Parallelize is still a fragile beast AFAIK. $\endgroup$
    – chris
    Commented Nov 16, 2012 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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