# Non-autonomous ODE use NDSolve, error: Step Size is effectively zero; singularity or stiff system is suspected

I have seen this error NDSolve::ndsz many times when I use NDSolve to get the solution of a non-autonomous ODE. I try but all failed. Thanks, Here is the code, very simple

 s = NDSolve[{x'[t] == 0.3 y[t],
y'[t] == -0.1 x[t] - 0.01 y[t] + 0.2 y[t]^2 + 0.5 Cos[2 Pi t] + 4,
x[0] == 1, y[0] == 1}, {x[t], y[t]}, {t, 0, 50 Pi}]

ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, 50 Pi},  PlotStyle -> Red]

• ParametricPlot won't show the graph properly. I don't know this way is suitable,the following works: ListPlot[Table[Evaluate[{x[t], y[t]} /. s], {t, 0, 50 Pi}], PlotStyle -> Red] Jan 17 '19 at 2:11
• NDSolve is very robust for initial value problem (IVP) of ODEs, if it fails on such problem, the equation system itself is probably wrong. Just check: Plot[Evaluate[{x[t], y[t]} /. s], {t, 0, 1.53}, PlotRange -> All] Jan 17 '19 at 2:17
• @Xminer Your code is not working properly, notice the domain of s is {0., 1.53703}. Jan 17 '19 at 2:23
• It's pretty clear that once y[t] > 0 and y[t]^2 > 0.1 x[t] + 0.01 y[t] that a singularity will develop in finite time. To me that doesn't mean the code is wrong. But if there's some reason why the actual problem should not have a singularity, then, yes, the code is not set up right. Here's an easy way to plot the solution: s = NDSolve[{x'[t] == 0.3 y[t], y'[t] == -0.1 x[t] - 0.01 y[t] + 0.2 y[t]^2 + 0.5 Cos[2 Pi t] + 4, x[0] == 1, y[0] == 1}, {x, y}, {t, 0, 50 Pi}]; ListLinePlot[{x, y} /. First@s] Jan 17 '19 at 2:38
• Here's an IC without a singularity: s = NDSolve[{x'[t] == 0.3 y[t], y'[t] == -0.1 x[t] - 0.01 y[t] + 0.2 y[t]^2 + 0.5 Cos[2 Pi t] + 4, x[0] == 50, y[0] == -1}, {x, y}, {t, 0, 50 Pi}]; Graphics[{Blue, Thick, Line[ Transpose[{x["ValuesOnGrid"], y["ValuesOnGrid"]} /. First@s]]}, Frame -> True] Jan 17 '19 at 2:38