# ParallelSum in Mathematica 9 vs 10

Here's part of a package I'm working on:

BeginPackage["TestPackage"]

reduction::usage = "reduction[x] returns x after some rules have been applied.";

Begin["Private"]

auxReduction1[exp_]:=Module[{matched,pointsMatched},

If[StringMatchQ[ToString[exp,InputForm],{"*θ"~~DigitCharacter..~~"θ"~~DigitCharacter..~~"^2*"}]==True,
matched=ToExpression[StringCases[ToString[exp,InputForm],"θ"~~DigitCharacter..~~"θ"~~DigitCharacter..~~"^2"]];
pointsMatched=StringCases[ToString[matched[[1]]],"θ"~~x:DigitCharacter..->x];
(exp/.{matched[[1]]->1})(-(1/2)ToExpression["θ"~~pointsMatched[[1]]~~"sq θ"~~pointsMatched[[2]]~~"sq"]),

exp
]
]

(*This function allows the application of the previously defined function on a sum of terms*)
auxReduction2[exp_]:=Module[{auxList,i,ans},
auxList=Flatten[{Replace[exp,HoldPattern[Plus[a___]]:>{a}]}];(*Create list of the terms in the sum*)
ans=ParallelSum[auxReduction1[auxList[[i]]],{i,1,Length[auxList]},DistributedContexts->Automatic]
]

reduction[exp_]:=FixedPoint[auxReduction2,exp];

End[]

EndPackage[]


In Mathematica 9 this works just fine. In Mathematica 10, shadowing messages appear the first time I use the function defined in the package. For example, if I run

reduction[θ1θ2^2]


then I get the message

Globalθ1sq::shdw: Symbol θ1sq appears in multiple contexts {Global,System}; definitions in context Global may shadow or be shadowed by other definitions.


and after it the expected answer.

Why is this happening in Mathematica 10 but not 9? By the way if Sum is used instead of ParallelSum`, then everything works fine in both Mathematica 10 and 9.

• I can confirm that both MMA 8 and 9 don't generate this error message and that MMA 10 does indeed yield this message. Looks like a bug to me. I'd suggest reducing this example to the bare bones, and submitting it to [email protected]. Jul 20, 2014 at 15:52