polylib::randpoly
-- creates a
random polynomialpolylib::randpoly
()
returns a univariate
random polynomial with integer coefficients; the global identifier
x
is used as an unknown.
polylib::randpoly
(list)
returns a random
polynomial in all unknowns given in list
.
polylib::randpoly
(list, ring)
returns a
random polynomial in the identifiers given in list
over
the coefficient ring ring
.
polylib::randpoly()
polylib::randpoly(list <, Degree= n>
<, Terms= k> <,Coeffs= f>)
polylib::randpoly(ring <, Degree= n>
<, Terms= k> <,Coeffs= f>)
polylib::randpoly(list, ring <, Degree=
n> <, Terms= k> <,Coeffs= f>)
list |
- | list of unknowns |
ring |
- | coefficient ring |
Degree= k |
- | determines the maximum degree the result can have in
each variable. k must be a non-negative integer. Default
is 6. |
Terms= t |
- | makes polylib::randpoly generate the sum
of t random terms. t must be a positive
integer or infinity .
If t equals infinity ,
polylib::randpoly returns a dense polynomial. Default is
5. |
Coeffs= f |
- | Create the coefficients of the result by calling
f() . |
a polynomial in the given unknowns over the given ring. If no list
of indeterminates is given, [x]
is used. If no ring is
given, Expr
is used.
poly
for a
detailed description of possible unknowns and coefficient rings.Terms=infinity
is given. Each term is created by generating its coefficient and its
degree vector at random. Since the same degree vector may be generated
several times, the actual number of terms in the result can be smaller
than the value of the option Terms
.f()
,
if the option Coeffs=f
is given. If this option is missing
and ring
is Expr
the coefficients will be
random integers in the range -999..999. If ring
is a user-defined domain, it must have a method "random"
to create the coefficients if no function is given.We generate a univariate random polynomial and use the default values for the options. Six random monomials are generated and added. Since it is unlikely that each of the possible exponents 0 to 5 is generated exactly once, the result is very likely to have less than six terms.
>> polylib::randpoly([z])
5 4 3 poly(663 z - 764 z - 806 z + 381 z, [z])
We create a bivariate random polynomial over the finite
field with 7 elements. This works because Dom::IntegerMod
has a
"random"
slot that generates random elements:
>> polylib::randpoly([x,y],Dom::IntegerMod(7),Degree=3,Terms=4);
3 2 2 poly(2 x y + 6 x y + 5 x, [x, y], Dom::IntegerMod(7))
randpoly