0

When you use the bisection method to find the roots of a function $f(x)$, you have to start with values $a$ and $b$ such that $f(a)$ and $f(b)$ have different signs- so (by the intermediate value theorem) you can find a root between $a$ and $b$. Only thing is... I'm automating the process with some code, and the code is supposed to be very general- so any combinations of regular algebraic arithmetic, trigonometry, logarithms, and hyperbolic functions.

This makes it pretty hard to estimate $a$ and $b$ on the spot such that they have opposite signs. Is there any way I can do this (without randomizing $a$ and $b$ and then running values through the same function to hone them down until they have separate signs)?

Thanks

Edit: I'm using an algorithm called Lehmer-Schur which is generalized to complex values using disks rather than a specific interval. I realize that it would be a lot simpler to pick really big bounds or try using some kind of randomizer, but this seems really crude and I was hoping there'd be a better solution. This is a big ask since (within the restrictions on composition mentioned above) there are no limits on the complexity of the function- so I understand that this may not be possible at all. I'm just keen to know what other people are doing or if there are any smart solutions.

Arctic Char
  • 16,972
MukundKS
  • 393
  • This is pretty standard. If you search you will find this algorithm written in many languages. – John Douma Nov 16 '20 at 07:18
  • Technically it's not the true bisection method- it's a variant called Lehmer-Schur (for complex values- so it works quite a bit differently to simple bisection), of which I can't find many sources, let alone code, let alone one that actually uses a smart technique. Most pick numbers with a big range or do the randomizer thing. I've updated the post to reflect this. – MukundKS Nov 16 '20 at 07:35
  • Consider this: If you can find two values with opposite signs very easily, why do you need the bisection anymore? The point of this method is that you no nearly nothing and do crude operations. – Nurator Nov 17 '20 at 10:58
  • @Nurator Your statement that "The point of this method is that you no nearly nothing and do crude operations" is unclear to me. The Lehmer-Schur algorithm relies on root-counting, so a root-finding method which does not depend on the values of the output is needed. – Simply Beautiful Art Nov 17 '20 at 14:17
  • 2
    You mention the Lehmer-Schur method, which is made for polynomials, though you did not say this in your question. It makes a big difference. –  Nov 17 '20 at 14:23
  • @YvesDaoust I don't see any issue with asking such a question and providing the context to which it is from. Answers can still answer the more general question while being more specifically useful to the particular case the OP is interested in. – Simply Beautiful Art Nov 17 '20 at 14:36
  • @YvesDaoust The use of bracketing methods is still the same, which is the concern of the question. The OP explicitly states they want the code to be general-use, which implies they care about that. It is fine to point out that the specific case for which they are using their code may be tackled by other means, but you can't decide what the OP does or doesn't care about. – Simply Beautiful Art Nov 17 '20 at 15:13
  • @SimplyBeautifulArt: the question is lacking focus. The resolution of polynomial equations and general equations are two different chapters of numerical analysis. –  Nov 17 '20 at 15:40
  • @SimplyBeautifulArt : There is no sign-oriented bisection (reducing intervals containing a root) in the complex plane. The related methods apply exclusion principles to carve out root-free regions in some initial region, to end up with small regions that may contain root clusters. The question makes no sense, for polynomials there exist root radius estimates, but the mentioned compositions are not polynomials. – Lutz Lehmann Nov 17 '20 at 16:15
  • @YvesDaoust Just because you can tackle polynomials using more specific methods does not mean you cannot tackle polynomials with general methods. I fail to see how this means the question lacks focus either. – Simply Beautiful Art Nov 17 '20 at 17:11
  • @LutzLehmann I don't see how the question fails to make sense. They are asking about picking initial points to apply bracketing methods, and one scenario they intend to use this is for the Lehmer-Schur algorithm. Likely to isolate the radii for the roots they wish to use bisection. – Simply Beautiful Art Nov 17 '20 at 17:14
  • @SimplyBeautifulArt : The Lehmer-Schur method for the complex plane is not a bracketing method. Do you have a reference to an implementation where some radius is determined via bisection? When I rewrote the wiki article from the original Lehmer paper, I did not find such. – Lutz Lehmann Nov 17 '20 at 18:22
  • @LutzLehmann I only figured the OP was motivated to do such. It would seem to me that one would bracket $f(R)-\alpha$ in $R$, where $f(R)$ is the number of roots with magnitude $<R$ and $\alpha$ a positive non-integer to detect when $f(R)$ passes between $\lfloor\alpha\rfloor$ and $\lceil\alpha\rceil$. – Simply Beautiful Art Nov 17 '20 at 18:56

1 Answers1

1

There is no issue with choosing very large brackets for a function, because the bracket will close in on the root very rapidly. To accelerate initial convergence to find the order of magnitude of the root, see here and here. The given routines will guarantee convergence in roughly 70 iterations over the largest finite bracket using doubles (somewhat useless if you don't care about relative accuracy).

If the values at infinity give the same sign (i.e. $f(\infty)=f(-\infty)=\pm\infty$), then you can try using optimization methods on that bracket to attempt to find how close it gets to the opposing infinity (i.e. $f(x)\to\mp\infty$). If there is a sign change, then you have two brackets (from the relative extrema to each infinity), and if there is no sign change then you really have no guarantee on the existence of a root. You may also wish to consider the case when $|f(x_\text{relative-extrema})|$ is very small as a double (or higher) root.

If the root is expected to be simple, then superlinear convergence may be obtained by using better bracketing methods, such as Chandrupatla's method. Feel free to look into the source code on GitHub and take out the portions that fit your needs.

  • When the are several roots, choosing very large brackets is just out of question. –  Nov 17 '20 at 14:15
  • @YvesDaoust I am not sure what you mean. – Simply Beautiful Art Nov 17 '20 at 14:18
  • With large brackets you can (will) miss all roots, obviously –  Nov 17 '20 at 14:21
  • Yes, this is only for finding one root of a function. If several roots are desired then you will need to use several separated brackets. As far as the OP's purposes however, these brackets will come naturally on their own. – Simply Beautiful Art Nov 17 '20 at 14:24
  • No you don't understand. If the function has several roots, large bracketing can fail to find any. Not one. Zero. Nada. –  Nov 17 '20 at 14:25
  • My answer already states what one can try to do if a large bracket fails to bracket any roots. Note that I'm only describing a rather general situation for finding one root, beyond this one would need to know more specifics concerning the nature of the function or its special values. This is also geared mostly towards the Lehmer-Schur algorithm, where there is good reason for the use of large brackets. – Simply Beautiful Art Nov 17 '20 at 14:31