# ParametricPlot3D and ParametricPlot don't plot on my machine but do on other machines

I tired visualizing the field lines of the electric field of two point charges (one positive, one negative) but whenever I try to do a ParametricPlot I just receive an empty plot as output (no errors). When I execute the same program on the PC of a friend it works without problems and did the plot like it was supposed to do. Does anybody have an idea why this happens and how it can be solved?

The field line is plotted from a given point parametrized over its own length and calculated with NDSolve and when I checked the output tables it was filled with values that seemed to be correct, just the plotting doesn't work.

Here's my code:

phi1[x_, y_, z_] := (1/Sqrt[(x - 1)^2 + (y - 1)^2 + z^2]) - (1/
Sqrt[(x + 1)^2 + (y + 1)^2 + z^2]);
f1[x_, y_, z_] = Grad[phi1[x, y, z], {x, y, z}];
g1[x_, y_, z_] = f1[x, y, z]/Norm[f1[x, y, z]];

FieldLineFW[f_, r0_ , smax_] := NDSolve[{
rx'[s] == f[rx[s], ry[s], rz[s]][[1]],
ry'[s] == f[rx[s], ry[s], rz[s]][[2]],
rz'[s] == f[rx[s], ry[s], rz[s]][[3]] ,
rx[0] == r0[[1]],
ry[0] == r0[[2]],
rz[0] == r0[[3]]},
{rx, ry, rz}, {s, 0, smax}, AccuracyGoal -> 2];

FieldLineBW[f_, r0_ , smax_] := NDSolve[{
rx'[s] == -f[rx[s], ry[s], rz[s]][[1]],
ry'[s] == -f[rx[s], ry[s], rz[s]][[2]],
rz'[s] == -f[rx[s], ry[s], rz[s]][[3]] ,
rx[0] == r0[[1]],
ry[0] == r0[[2]],
rz[0] == r0[[3]]},
{rx, ry, rz}, {s, 0, smax}, AccuracyGoal -> 2];

maxT=6;
ParametricPlot3D[
Evaluate[
Join[ParallelTable[
{rx[t], ry[t], rz[t]} /.
FieldLineFW[g1, {x , y , z }, maxT], {x, {-3, -1, 0, 1,
3}}, {y, {-0.5, 0, 0.1, 0.5, 2}}, {z, {-0.5, 0.1, 0.5, 2}}
], ParallelTable[
{rx[t], ry[t], rz[t]} /.
FieldLineBW[g1, {x , y , z }, maxT], {x, {-3, -1, 0, 1,
3}}, {y, {-0.5, 0, 0.1, 0.5, 2}}, {z, {-0.5, 0.1, 0.5, 2}}
]]
], {t, 0, maxT}, AxesLabel -> {"x/[m]", "y/[m]", "z/[m]"}]


The error also occurred when I used Table instead of ParallelTable but it did not occur when I just used a single point to plot the field line (but a plot with just one field line is not very helpful). I hope somebody had a similar problem and could solve it or anybody knows why this issue appears on my machine but not on others.

I am using the Student Edition of Mathematica 11.2.0 and I work with macOS 10.13.2 High Sierra and Ubuntu 17.10 (neither Mac nor Ubuntu worked, I also tried evaluating it on Windows in a virtual machine, didn't work either). As said in the beginning it did work on a friend's PC (Windows 10) and also at the PCs at university (Debian 8) it worked.

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Dec 27 '17 at 3:21

The code as written in the question contains an error. Specifically, the first argument of ParametricPlot3D must be a one-dimensional List of curves, but the first argument in the question is nested three levels deep and must be Flattened. It also is more efficient not to compute the curves inside the first argument. Instead, write,

curves = Flatten[Join[
ParallelTable[{rx[t], ry[t], rz[t]} /. FieldLineFW[g1, {x , y , z }, maxT],
{x, {-3, -1, 0, 1, 3}}, {y, {-0.5, 0, 0.1, 0.5, 2}}, {z, {-0.5, 0.1, 0.5, 2}}],
ParallelTable[{rx[t], ry[t], rz[t]} /. FieldLineBW[g1, {x , y , z }, maxT],
{x, {-3, -1, 0, 1, 3}}, {y, {-0.5, 0, 0.1, 0.5, 2}}, {z, {-0.5, 0.1, 0.5, 2}}]], 3];


(Notice that Flatten here eliminates the top three levels of nesting.) Then,

ParametricPlot3D[curves, {t, 0, maxT}, AxesLabel -> {"x/[m]", "y/[m]", "z/[m]"},
ImageSize -> Large, LabelStyle -> Directive[Bold, Black, Medium]]


• I noticed this too and got it to work with Flattern. But the OP said the code works as is on another machine, which is what confused me about this question. go figure :) – Nasser Dec 27 '17 at 3:40
• @Nasser Perhaps, the OP was mistaken. Without actually seeing the code run on the other computer, it is difficult to draw conclusions. – bbgodfrey Dec 27 '17 at 4:42
• The code did really work as is on my PC at university while I was sitting in front of it (Debian 8 and Mathematica 11.0.0) but I have no idea why. However the Flatten did work for me so thanks for your help! I'd like to click the checkmark sign as you said but because I asked this question as a guest and just created my account with a different e-Mail address I don't really know how to do that so please consider this thread as closed. – fdg13gustav Dec 29 '17 at 1:31