NDSolve error (not a real number when the arguments are?)

For the NDSolve, I have problem. It seems to be non-zero imaginary part of the number. How can I get over this issue? The following is the script.

a = 5;
b = 10;
c = 200;
d = 1675000;
Array[f, c];
Array[g, {a, b}];
Array[g2, b];
k = 1; While[k <= b, Do[g[t, k] = 0, {t, a}]; k++];
k = 1; While[k <= b, g2[k] = 0; k++];

G = 2.68;

Z = 2.9;

n = 1; While[n <= c, f[n] = NDSolve[{y''[x] == 1.2*Cos[(y[x]) + Arg[Exp[3*I*x]]],
y'[0] == 2.606, y[0] == (n - 1)/c*2*Pi - Pi}, y, {x, 0, 1}]; n++];

NDSolve::nrnum1: The function value 1. +0.000275068 I is not a real      number when the arguments are {0.0000916894,1}. >>

NDSolve::nrnum1: The function value 1. +0.000275068 I is not a real number when the arguments are {0.0000916894,1}. >>

NDSolve::nrnum1: The function value 1. +0.000550136 I is not a real number when the arguments are {0.000183379,1}. >>

General::stop: Further output of NDSolve::nrnum1 will be suppressed during this calculation. 


The problem is that Arg is discontinuous and your ODE explicitly contains an imaginary I. The Arg invokes discontinuity processing, which constructs an event function. The I probably causes the use of complex numbers internally, even though they are unnecessary. The event functions usually detect events as zero crossings. Zero crossings are not well-defined if the numbers used are complex. I suspect that is the source of the error.
Try using ArcTan[Cos[3x], Sin[3x]] instead of Arg[Exp[3*I*x]]. The errors go away.
• Plausible. An evidence is, if one set Method -> "DiscontinuityProcessing" -> False in NDSolve, the warning goes away, too. The result is the same as using ComplexExpand@Arg[Exp[3*I*x]]`. – xzczd Oct 2 '17 at 4:11