# Finding jumps/discontinuities in a univariate function

I want to find jumps (or at least one jump, if it exists) in a univariate function on a given interval. Eg looking for a jump in

``````f(x) = x > 0 ? one(x) : zero(x)
``````

on [-2,2] should give me \approx 0.

I searched the literature and found that this is called “edge detection” in image processing, but in contrast, I can readily evaluate the function just anywhere, also, I just need univariate. I have no derivatives (that I would trust).

I am aware that such algorithms are heuristic, may not find edges and may return bogus ones. This is just needed for a plotting problem though. I am not familiar with these algorithms and thought of asking before devising my own, so suggestions for specific Julia packages, or papers/textbooks to read, would be welcome.

I don’t know if a Julia implementation, but Chebfun has a nice algorithm for doing this. I believe it’s built on using bisection, so if you only need one jump should be easy to implement.

Can you look for large absolute values of diff(x)?

After some digging, I found the algorithm described in

``````@article{pachon2010piecewise,
title={Piecewise-smooth chebfuns},
author={Pach{\'o}n, Ricardo and Platte, Rodrigo B and Trefethen, Lloyd N},
journal={IMA journal of numerical analysis},
volume={30},
number={4},
pages={898--916},
year={2010},
publisher={OUP}
}
``````

Specifically, it is `detectedge(f, a, c)` on page 8, and is conceptually very simple: calculate f, f', f'', f''' by differences on a grid, select the largest one, refine that cell, and see if the derivatives increased. I should be able to adapt this easily for my purposes.

@dpsanders: This is what the above method uses, except with a recursive refinement.

Thanks for all the help.

1 Like

Great! If you implement it, I might incorporate it into ApproxFun.

1 Like