# NDSolve equation gives empty plotting

ClearAll[n, c, w1, w2, x, y, g, p1, p2, p3, p4, Eq1, Eq2, sol]

n = 1;

w1 = -(1/3) - 2*(Sqrt[g[x]]*Sqrt[1 - g[x]/y[x]])/3;

w2 = (0.2)*(1 + y[x])^n/(g[x])^(n - 1)*(1 - g[x] + y[x]);

Eq1 = g'[x] == -3*g[x]*(1 - g[x] + y[x])*(w1 - w2) +
y[x]*g[x]*(1 + 3*w1);

Eq2 = y'[x] == -3*y[x]*(1 - g[x] + y[x])*(w1 - w2) +
y[x]*(1 + y[x])*(1 + 3*w1);

sol = NDSolve[{Eq1, Eq2, g[0] == 0.72, y[0] == 0.08}, {g, y}, {x, -10,
10}, AccuracyGoal -> 2];

p1 = Plot[{Evaluate[{g[x],y[x]} /. sol]}, {x, -10, 10}];


when I try to solve equations the graphs are empty, how can I solve that?

• Remove MaxSteps -> 500 Commented Feb 13, 2017 at 17:44
• ok. why my graphs are empty, it is not plotting Commented Feb 13, 2017 at 17:49
• At x==0, g'[x] and y'[x] are complex-valued ({Eq1, Eq2} /. {g[x] -> 0.72, y[x] -> 0.08} gives {Derivative[1][g][x] == 0.319666 + 0.96768 I, Derivative[1][y][x] == 0.0355185 - 0.27648 I}). Is that what you expect? I notice you changed the definition of w1 in your edit. Commented Feb 13, 2017 at 18:16

Real Part

ClearAll[n, w1, w2, p1, sol]

n = 1;

w1[x_] := Re[-(1/3) - 2*(Sqrt[g[x]]*Sqrt[1 - g[x]/y[x]])/3];

w2[x_] := Re[(1/5)*(1 + y[x])^n/(g[x])^(n - 1)*(1 - g[x] + y[x])];

sol = NDSolve[{
g'[x] == -3*g[x]*(1 - g[x] + y[x])*(w1[x] - w2[x]) + y[x]*g[x]*(1 + 3*w1[x]),
y'[x] == -3*y[x]*(1 - g[x] + y[x])*(w1[x] - w2[x]) + y[x]*(1 + y[x])*(1 + 3*w1[x]),
g[0] == 0.72, y[0] == 0.08},
{g, y}, {x, -10, 10}];

p1 = Plot[{Evaluate[{g[x], y[x]} /. sol]}, {x, -10, 10},
PlotStyle -> {Blue, Red}, Axes -> None, Frame -> True]

p2 = Plot[{Evaluate[w1[x] /. sol], Evaluate[w2[x] /. sol]}, {x, -10, 10},
PlotStyle -> {Blue, Red}, PlotRange -> Full, Axes -> None, Frame -> True]


Imaginary Part

w1[x_] := Im[-(1/3) - 2*(Sqrt[g[x]]*Sqrt[1 - g[x]/y[x]])/3];

w2[x_] := Im[(1/5)*(1 + y[x])^n/(g[x])^(n - 1)*(1 - g[x] + y[x])];