1

I'm looking for advice to pick a numerical method to find all roots of a univariate function $f$ on a finite interval:

  • $f$ is Lipschitz-continuous with unknown $L$ (without that assumption, it is hopeless anyway)
  • $f$ is a black box and costly to evaluate, (no derivatives known, finite differences are too costly)

The hard part is to nail down an interval around each root, then e.g. Regula Falsi finds the root quickly.

The function $$f : [0,1] \mapsto \sqrt{x} \cos\left(\frac{1}{\log(x+1.05)}\right)$$ is a good test case, which (the best I got) took about 60 calls to get all 7 roots. Here you have an example of how $f$ in general can look like. Thanks in advance!

m

Remark: The method has to be implemented in hlsl for a shader using single-precision floating-point format, such that a rather simple and deterministic algorithm which does not involve matrix-algebra is preferred.

darksun
  • 341

1 Answers1

1

If $L$ is not known, and the number of roots is also not known, then I do not see how any algorithm can guarantee that it has found all the roots. If $L$ is sufficiently large, then it is possible that there is another root in between two of the roots that have been found. So you will have to use an ad hoc termination criterion to decide that there are no more roots.

With no knowledge of the function and its roots, I would think that the best procedure would be to keep evaluating the function at points chosen randomly, and whenever two points ($x$ and $y$) have been found such that $f(x)$ and $f(y)$ are of opposite sign, use the Brent algorithm to find the root between them (a root is guaranteed by the intermediate value theorem since $f$ is continuous). Instead of choosing points randomly, you can also choose them a fixed distance apart (and keep reducing this fixed distance), but random is easier to code and would probably work as well. You could also sample randomly and discard any point that is too close to a point at which the function has already been evaluated (either by the random process or by the Brent algorithm).

Another possibility is that after enough points have been evaluated, the function can be approximated using a spline or LOESS. Roots of this approximation can be found by standard means as evaluation of the approximate function is very cheap. You could then try to find a root of the original function in an interval around the root of the approximate function.

  • I was hoping $L$ could be estimated along the way, as in some optimization algorithms. But that might require a large number of evaluations anyway. Brent or Dekker's method is a good pick for the final, thanks. – darksun Jun 15 '25 at 08:20