I am looking at a particle moving in a funny potential, described by the following differential equation. The solution should be just some kind of periodic trajectory, why is there a problem here?
Edit: here is the code:
k = NDSolve[{x'[t]^2 + 1/Cos[x[t]]^2 == 2, x[0] == 0},
x[t], {t, 0, 4}]



x[t]to be real your ode evaluates negativex'[t]^2for x[t]>= Pi/4 !!! That's whyNDSolvestops forx[t]==Pi/4. – Ulrich Neumann Aug 11 '21 at 16:521/Cos[x[t]]^2will get larger than 2 and the other term is squared. – Coolwater Aug 11 '21 at 18:33x'[t] == 0: The solution should be constant, not oscillatory. Check outNDSolve[{x'[t]^2 + 1/Cos[x[t]]^2 == 2, x[0] == Pi/4}, x, {t, 0, 4}, Method -> {"EquationSimplification" -> "Residual"}]. The reason it's does not become constant in Domen's answer is that numerical error prevents the solution from reaching equilibrium. That's also why your code failed, although the different methods lead to different outputs. – Michael E2 Aug 11 '21 at 23:32x’[t]approach each other asx[t]approaches either singular solutionx[t] == ±Pi/4. One solution leads towards the singular solution and the other leads away. The step size decreases as the solution gets close to±Pi/4, but eventually the implicit solver accidentally finds the branch leading away from the singular solution. I may answer in time. – Michael E2 Aug 12 '21 at 14:19