up previous next
Randomized

randomize the coefficients of a given polynomial
Syntax

Randomized(F:POLY or INT):POLY or INT

where V is a variable containing a polynomial.


Description
This function with a polynomial argument returns a polynomial obtained by replacing the coefficients of F with randomly generated coefficients. The original polynomial, F, is unaffected. With an integer argument, it returns a random integer.

Note: It is possible that some coefficients will be replaced by zeroes, i.e., some terms from the original polynomial may disappear in the result.

The similar function Randomize performs the same operation, but returns NULL and modifies the argument.

NB: every time you restart CoCoA the sequence of random numbers will be the same (as in other programming languages). If you want total randomness read Seed .

Example
  Use R ::= QQ[x];
  F := 1 + x + x^2;
  Randomized(F);
-2917104644x^2 + 3623608766x - 2302822308
-------------------------------
  F;
x^2 + x + 1
-------------------------------
  Randomized(23);
-3997312402
-------------------------------
  Use R ::= ZZ/(7)[x,y];
  Randomized(x^2 + 3x - 5);
3x^2 + 2x - 2
-------------------------------


See Also