Skip to main content

Find all the roots (zeros) of a complex analytic function within a given contour in the complex plane.

Project description

pkg_img tests pyup


cxroots is a Python package for finding all the roots of a function, f(z), of a single complex variable within a given contour, C, in the complex plane. It requires only that:

  • f(z) has no roots or poles on C
  • f(z) is analytic in the interior of C

The implementation is primarily based on [KB] and evaluates contour integrals involving f(z) and its derivative f’(z) to determine the roots. If f’(z) is not provided then it is approximated using a finite difference method. The roots are further refined using Newton-Raphson if f’(z) is given or Muller’s method if not. See the documentation for a more details and a tutorial.

With Python installed you can install cxroots by entering in the terminal/command line

pip install cxroots


from numpy import exp, cos, sin
f = lambda z: (exp(2*z)*cos(z)-1-sin(z)+z**5)*(z*(z+2))**2

from cxroots import Circle
C = Circle(0,3)
roots = C.roots(f)
 Multiplicity |               Root
      2       | -2.000000000000 +0.000000000000i
      1       | -0.651114070264 -0.390425719088i
      1       | -0.651114070264 +0.390425719088i
      3       |  0.000000000000 +0.000000000000i
      1       |  0.648578080954 -1.356622683988i
      1       |  0.648578080954 +1.356622683988i
      1       |  2.237557782467 +0.000000000000i

See also

The Fortran 90 package ZEAL is a direct implementation of [KB].

Citing cxroots

R. Parini. cxroots: A Python module to find all the roots of a complex analytic function within a given contour (2018),


  author = {Robert Parini},
  title = {{cxroots: A Python module to find all the roots of a complex analytic function within a given contour}},
  url = {},
  year = {2018--}

Release Procedure

Making a release on GitHub with the tag vX.Y.Z will update the documentation on master and push cxroots at the tagged commit to PyPI


[KB](1, 2) P. Kravanja and M. Van Barel. Computing the Zeros of Analytic Functions. Springer, Berlin, Heidelberg, 2000.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cxroots-1.1.11.tar.gz (35.8 kB view hashes)

Uploaded source

Built Distribution

cxroots-1.1.11-py3-none-any.whl (47.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page