Exclude points from a set of points which prevent them from approximating a function

106 Views Asked by At

I am currently writing a small program in python for some calculations and to also learn python. I don't have a problem with python itself at the moment but I lack any idea how I could solve the following challenge I encountered when wanting to approximate integrals.

I have a set of points which in the end should approximate an function which I can't solve symbolically. The problem is when I generate those points I get "artifacts". By that I mean points which do not belong on the function. Here is an example which I plotted. On the top right the index is small and gets bigger to the bottom left. Of course there is the loop which forms the sharp bend. All points have different x-values, so I can't really use them as no two points will lay directly above one another.

In the end I only want the lower points, such that the approximated curve is a function. I have tried of ways to find the intersection where I have the sharp bend but I could not identify that point. My idea was to find the intersection by looking for a point with a relatively small index and see if there is a very close point which has a much higher index but a smaller y-value. But with that method I find many possible candidates but can't find the best one without excessive computations.

Unfortunately I can't change the way to find these point, so there is no way to prevent these artifacts...

So I am asking for ideas how an algorithm could work which can reliable remove such artifacts. I hope my questions is clear and fit for math.stackexchange and thanks in advance!