Search code examples
numerical-methods

Finding zeros of a function


I have a function of this kind

f(x)=alpha+beta \sum_i A_i/(x-B_i)

where alpha, beta, A_i and B_i are real numbers. I want to find numerically all the zeros of f(x) (I want to consider only the zeroes on the real axis).

What would be the best strategy/algorithm for this purpose?

For this function x=B_i are asymptotes, so let's say that I can restrict the search in the interval [B_i,B_{i+1}] (I am supposing that B_1 < B_2 <...< B_N). In general, f(x) will have more than one zero in the interval [B_i,B_{i+1}].


Solution

  • Use simple algebra to recast the function so the whole thing is a single polynomial over a common denominator:

    denominator(x) = \product_i (x-B_i)
    

    The numerator will be a polynomial, and the roots of that polynomial will be the roots of the whole function. You can then use any one of a variety of root-finding methods with that simple polynomial:

    https://en.wikipedia.org/wiki/Root-finding_algorithm#Finding_roots_of_polynomials

    Your insight that the roots will be in intervals between zeroes of the denominator will no doubt be useful. Make sure that none of the roots of the numerator coincide with roots in the denominator, in which case you'll have to cancel a common factor and try again.