Adding a threshold in numerical codes

1. May 16, 2010

matteo86bo

Hi,
I noticed such a strange behavior in my code every time I add a threshold: little oscillation around the threshold value itself.

For example
$$f(x) = g(x), x > x_c$$
$$f(x) = 0, x <= x_c$$
$$\frac{dx}{dt}=f(x)$$

I solve the last equation and I find this oscillation. Can they be removed?

2. May 16, 2010

mathman

It sounds like it is a numerical problem. Computer codes are often subject to such difficulties.

3. May 17, 2010

matteo86bo

Yes, I definitely believe it's a numerical problem. I have no improvement if I solve the equation in a thicker grid.