CountRoots

CountRoots[f,x]

gives the number of real roots of the univariate function f in x.

CountRoots[f,{x,a,b}]

gives the number of roots between a and b.

Details

  • CountRoots counts roots with multiplicities.
  • The function f can be polynomial, holomorphic or meromorphic etc.
  • Roots that lie exactly at x=a or x=b are counted.
  • The limits a and b can be complex, in which case the range is taken to be the closed rectangle Re[a]Re[x]Re[b]Im[a]Im[x]Im[b].

Examples

open allclose all

Basic Examples  (4)

Count the number of polynomial roots between 0 and 10:

Count roots of a polynomial in a closed rectangle:

Count roots of a real elementary function in a real interval:

Count roots of a holomorphic function in a closed rectangle:

Scope  (20)

Basic Uses  (8)

Find the number of the real roots:

Count roots in a real interval:

Count roots in a closed rectangle:

Count roots in a vertical line segment:

Count roots in a horizontal line segment:

Multiple roots are counted with their multiplicities:

For a root of multiplicity , all the derivatives for also vanish:

Roots at the endpoints of the interval are included:

Roots on the boundary of the rectangle are included:

Real Elementary Functions  (6)

Count the real roots of a high-degree polynomial:

Find the number of non-negative roots of an algebraic function involving high-degree radicals:

Count the non-negative roots of a function involving irrational real powers:

Count the real roots of a real exp-log function:

Count the real roots of a tame real elementary function:

This shows the plot of the function:

Count roots of a real elementary function in a bounded interval:

This shows the plot of the function:

Holomorphic Functions  (3)

Count roots of a holomorphic elementary function in a closed rectangle:

Count roots of a holomorphic special function in a closed rectangle:

Find the number of roots of an analytic function in a bounded real interval:

The double root at zero is counted with multiplicity:

Meromorphic Functions  (3)

Count roots of a meromorphic elementary function in a closed rectangle:

Visualize roots and poles of the function:

Count roots of a meromorphic special function in a closed rectangle:

Visualize roots and poles of the function:

Find the number of roots of a meromorphic function in a bounded real interval:

Plot the function:

Applications  (4)

The number of 17^(th) roots of unity in the closed unit square in the first quadrant:

Roots on the boundary are counted:

Check that a function has exactly one root in an interval:

Use FindRoot to approximate the root:

Compute a contour integral of logarithmic derivative of a function using the formula , where is the number of roots for a holomorphic function :

Compare with the result of numeric integration:

Test stability of equilibria at 0 of linear dynamical systems by counting the roots of the CharacteristicPolynomial[m,x] in the right half-plane:

Use a bound for max absolute value of the roots:

Count the roots in the right half-plane:

Since all eigenvalues of m have negative real parts, the equilibrium is asymptotically stable:

Try a different matrix:

This time there are roots with non-negative real parts:

The equilibrium is not asymptotically stable:

Properties & Relations  (5)

The number of complex roots of a polynomial is equal to its degree:

This gives a bound on absolute values of roots of a polynomial:

The polynomial indeed has 10 roots within the Cauchy bounded region:

The number of real roots of a polynomial with nonzero terms is at most :

This polynomial has the maximal possible number of real roots:

Use Reduce to find polynomial roots:

Count roots:

Find roots:

Use RootIntervals to find isolating intervals for roots:

Count the real roots:

Isolate the real roots:

Use NumberFieldSignature to count the real roots and the pairs of complex roots of a polynomial:

Possible Issues  (1)

Roots at the endpoints of the interval are included:

Neat Examples  (1)

Count the roots of a meromorphic function:

Plot the roots as spikes:

Introduced in 2007
 (6.0)
 |
Updated in 2017
 (11.1)