I have a black box function f(x)
with the following criteria:
Within Python, I would like to get an algorithm that delivers to me - with the least amount of steps - the positions x0
, x1
where f
is greater or equal to a
.
It can be assumed that there exist values for x
where f(x)
is greater/equal than a
.
See this picture for visualizing the problem:
So my questions are:
bubble sort algorithm
when the task is to sort a list)?Looking for points where a function crosses the x-axis is zero-finding
or x-axis intercept finding. You can define a new function g(x) = f(x) - a then find the 'zeros' of the g(x) function.
The simplest way of finding intercepts is to find an xa and xb where g(xa) < 0 and g(xb) > 0. Then choose an xc midway between those and continue using xc and one of xa or xb (that has the opposite sign as xc). Repeat these steps again until the interval between x's is small enough to be considered 'found'.