Previous Page Next Page Contents

polylib::randpoly -- creates a random polynomial

Introduction

polylib::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.

Call(s)

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>)

Parameters

list - list of unknowns
ring - coefficient ring

Options

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().

Returns

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.

Related Functions

poly, random

Details

Example 1

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])

Example 2

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))

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000