Counting Roots
Sometimes we don’t need to know the precise location of every root, just how many there are.
We can use the count_roots()
method to just count the number of roots of an analytic function within a given contour.
The example below counts all the roots of \(f(z)=z^2(z+2)^2(z+4)^2\) within the circle \(|z|<3\).
from cxroots import Circle
f = lambda z: (z*(z+2)*(z+4))**2
C = Circle(0,3)
num_roots = C.count_roots(f)
print(num_roots)
4