Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing Numerical integration of ODEs. for a special system that has an always positive coordinate s and a conjugated momentum ps.

At some point the equations become so stiff that s becomes negative and if I improve tolerances of the numerical integrator, it crashes. To solve this problem, I'd like to approximate the ODEs with s_new=abs(s) and ps_new=-ps around the critical region (for example if(s<1.0e-8)). The problem is that these are not smooth. Numerical integrators (I use BDF) break down.

One solution that I came across is to use arctan for abs and erf for sign.

It was hard for me to find anything in literature on it. If you know of a better approach, please let me know. Note, there is conservation of energy, so there exist f(s,ps) such that df/dt=0

share|cite|improve this question
I know nothing about the problem domain, so I am not sure the following is what you are looking for. Instead of the $sgn(x)$ function, it is customary to use $\tanh (kx)$ for some large constant $k$. – fishlips Apr 1 '12 at 8:48

You can use: $2\Phi(x/\sigma) - 1$ as a good approximation to the signum function, where $\sigma$ is small relative to $x$.

share|cite|improve this answer

Are you sure that the failure of the integrator is due to lack of smoothness? It is quite possible to integrate over non-smooth conditions with standard techniques, depending on the character of the system.

If you say that you have a stiff problem, I would imagine that that would be the cause more than anything. Have you tried using a multi-step method instead of a BDF? An Adams-Moulton implicit linear multistep method might be more suitable, and you might be able to avoid this problem altogether. It would help if you posted your system in detail.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.