# Repeated convergence test failure and why?

i have assigned all the values and the ODE assigned is as this

equa00=0. - Piecewise[{{1.76 + (1/2)*(17.823981400755596 + 3.1865569652622434*Derivative[2][x][t] + 2*(11.76 + 1.2*Derivative[2][x][t])), Derivative[1][x][t] >= 0}, {1.76 + 40*(0.010436534400000001*Derivative[2][x][t] + (1/40)*(11.76 + 1.2*Derivative[2][x][t])), Derivative[1][x][t] < 0}}, 0] + 315.57298205309473*(0.08*Cos[2.7152918354276516*t] - x[t]) - 18.993139260437836*Cos[2.7152918354276516*t]*(0.04347647225924945 + 0.08*Cos[2.7152918354276516*t] - x[t]) +12.880529879718154*Abs[-0.21722334683421213*Sin[2.7152918354276516*t] - Derivative[1][x][t]]*(-0.21722334683421213*Sin[2.7152918354276516*t] - Derivative[1][x][t]) +32.201324699295384*Piecewise[{{0.8217543642879789573759622571839431.91474201927165, Derivative[1][x][t] >= 0 || Derivative[1][x][t] < 0}}, 0]*(0.04347647225924945 + 0.08*Cos[2.7152918354276516*t] - x[t])*(-0.5898247801232052*Cos[2.7152918354276516*t] - Derivative[2][x][t]) == 1.4*Derivative[2][x][t]

ts = 50;

(*the initial values will affect if it will converge*)
s1 = NDSolve[{equa00, x[0] == 0, x'[0] == 0}, x, {t, 0, ts},
SolveDelayed -> True]

picture2 = Plot[x[t] /. s1, {t, 0, ts}, PlotRange -> All]
picture3 = Plot[x'[t] /. s1, {t, 0, ts}, PlotRange -> All]


but the hints are

NDSolve::ndcf: Repeated convergence test failure at t == 0.; unable to continue. >>


and when the initial values changes,for example change it to x[0] == 0, x'[0] == 0.1 or x[0] == 0.1, x'[0] == 0,the hints will change,so hwo to deal with it?

and the codes were run in version 7

• Nov 26, 2019 at 6:38

approx = With[{k = 1000}, 1/Pi ArcTan[k #] + 1/2 &];
s1 = NDSolve[{SimplifyPWToUnitStep@equa00 /. UnitStep -> approx, x[0] == 0, x'[0] == 0},

The idea is not complicated: rewrite the Piecewise function with UnitStep, then replace UnitStep with its continuous approximation approx, so DAE solver of NDSolve (triggered by SolveDelayed -> True`) can handle the problem easier.