# Problem with ParallelTable?

I am trying to numerically solve Bloch equations using Euler's method. My code is the following

γ = 1.;
b = {0., 0., 1.};
θ = π/6.;
ϕ = 0.;
ic = {Cos[ϕ] Sin[θ], Sin[ϕ] Sin[θ], Cos[θ]};
m0 := ic;
m[Δt_] := m0 + Δt γ Cross[m0, b];
run[Δt_, n_] := Table[α = m[Δt]; ic = α, {t, 1, n}];
run1 = run[0.01, 1000];
ListPlot[Table[Flatten[Take[run1, All, {j}]], {j, 3}], Joined -> True,  PlotRange -> All, PlotStyle -> Thick]


This gives the correct result. However if I use ParallelTable instead of Table

run[Δt_, n_] := ParallelTable[α = m[Δt]; ic = α, {t, 1, n}];


I get the following

What is the cause of this? ParallelTable also takes longer than Table as well. Sorry I can't get the formatting of the greek letters correctly...

• Please copy and paste your code again from Mathematica and do not attempt to format the Greek letters. (They will appear as e.g. \[Phi].) Jan 21, 2015 at 22:21
• thank you. I re-copied the mathematica code. Jan 21, 2015 at 22:27
• For such a short calculation, the overhead of parallel computations dominates any savings from using multiple processors. Jan 21, 2015 at 22:35
• Hi bbgodfrey. This is the equation of motion for only one particle. Eventually I'd like to extend this to many interacting particles, which I was hoping paralleltable would be helpful. Jan 21, 2015 at 22:42
• The problem, I believe, is that each of the parallel processes is independently changing ic. Better, I believe to calculate trajectories of multiple particles in parallel than to try to compute the trajectory of one particle with multiple processors. Jan 21, 2015 at 22:49