random polynomial generator
indeterminate or list or set of indeterminates
(optional) equations or names specifying properties
A call to randpoly generates a random polynomial in vars. It is useful for generating test problems for debugging, testing, and demonstration purposes. Several options can be specified, determining the form of the polynomial. This allows for quite general expressions with certain properties.
The first argument vars specifies the variables in which the polynomial is to be generated. If vars is a single variable, a univariate polynomial in that variable is generated. If vars is a list or set of variables, then a multivariate polynomial is generated.
The possible options (and their default values) are:
generate the coefficients
generate the exponents
number of terms generated
total degree for a dense polynomial
the polynomial is to be dense
the polynomial is to be homogeneous
The terms option is intended for specifying the number of terms in sparse polynomials, where the numbers of terms is often significantly smaller than the maximum number of possible terms. The terms option will be overridden by the degree option. A call randpoly(x, terms=7) will return a polynomial with six terms, since the default degree is five. If you want a dense polynomial, simply use the dense option.
Note: If you use the terms option, some of the terms generated may have the same exponents. In this case, the corresponding coefficients will be added in the return value. As a result, the number of terms you see in the result is lower than the number actually generated, and the coefficients may be outside of the range specified. This is demonstrated in one of the examples below; see the note there.
randpoly([x], coeffs = proc() randpoly(y) end proc);
Note: The options coeffs and expons are used to generate the individual terms, which are added to form the polynomial. Thus, the generated polynomial may have coefficients outside the specified range. This is more likely if the requested number of terms is significantly larger than the required degree.
Download Help Document
What kind of issue would you like to report? (Optional)