Search code examples
pythonalgorithmmathematical-optimization

Optimization algorithm to find acceptable limits of a concave function


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:

enter image description here

So my questions are:

  • What would be the name for such an algorithm, if there is one (like there is e.g. the bubble sort algorithm when the task is to sort a list)?
  • How would an algorithm for my problem look like?
  • Alternatively: Is there a standard Python library for such task?

Solution

  • 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'.