Name:

numberroots Computes the number of roots of a polynomial in a given range.

Library name:

sollya_obj_t sollya_lib_numberroots(sollya_obj_t, sollya_obj_t)

Usage:

numberroots(p, I) : (function, range) -> integer

Parameters:

Description:

Example 1:

   > numberroots(1+x-x^2, [1,2]);
   1
   > findzeros(1+x-x^2, [1,2]);
   [|[1.617919921875;1.6180419921875]|]

Example 2:

   > numberroots((1+x)*(1-x), [-1,1]);
   2
   > numberroots(x^2, [-1,1]);
   1

Example 3:

   > verbosity = 1!;
   > numberroots(x-pi, [0,4]);
   Warning: the 0th coefficient of the polynomial is neither a floating point
   constant nor can be evaluated without rounding to a floating point constant.
   Will faithfully evaluate it with the current precision (165 bits)
   1

Example 4:

   > verbosity = 1!;
   > numberroots(1+x-x^2, [0, @Inf@]);
   Warning: the given interval must have finite bounds.
   Warning: at least one of the given expressions or a subexpression is not correctly typed
   or its evaluation has failed because of some error on a side-effect.
   error
   > numberroots(exp(x), [0, 1]);
   Warning: the given function must be a polynomial in this context.
   Warning: at least one of the given expressions or a subexpression is not correctly typed
   or its evaluation has failed because of some error on a side-effect.
   error
See also: dirtyfindzeros, findzeros, gcd
Go back to the list of commands