Difference between revisions of "RandomPolynomial Command"
From GeoGebra Manual
Line 3: | Line 3: | ||
;RandomPolynomial[ <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ] | ;RandomPolynomial[ <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ] | ||
:Returns a randomly generated polynomial in ''x'' of degree at most ''d'', whose (integer) coefficients are in the range from ''min'' to ''max'', both included. | :Returns a randomly generated polynomial in ''x'' of degree at most ''d'', whose (integer) coefficients are in the range from ''min'' to ''max'', both included. | ||
+ | {{example| 1=<div> | ||
+ | * <code><nowiki>RandomPolynomial[0, 1, 2]</nowiki></code> yields either ''1'' or ''2'' and | ||
+ | * <code><nowiki>RandomPolynomial[2, 1, 2]</nowiki></code> yields a random polynomial with a degree of two and only ''1'' and ''2'' as coefficients, for example ''2x<sup>2</sup> + x + <sup>1</sup>''. | ||
+ | </div>}} | ||
+ | {{note| 1=The coefficient of x to the power of ''d'' is guaranteed not to be zero.}} | ||
;RandomPolynomial[ <Variable Var>, <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ] | ;RandomPolynomial[ <Variable Var>, <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ] | ||
:Returns a randomly generated polynomial in ''Var'' of degree at most ''d'', whose (integer) coefficients are in the range from ''min'' to ''max'', both included. | :Returns a randomly generated polynomial in ''Var'' of degree at most ''d'', whose (integer) coefficients are in the range from ''min'' to ''max'', both included. | ||
− | {{note|In both cases if ''min'' or ''max'' are not integers, ''round(min)'' and ''round(max)'' are used instead.}} | + | :{{note|In both cases if ''min'' or ''max'' are not integers, ''round(min)'' and ''round(max)'' are used instead.}} |
+ | :{{note| 1=The coefficient of ''Var'' to the power of ''d'' is guaranteed not to be zero.}} |
Revision as of 09:43, 19 August 2011
This command works in CAS View only.
- RandomPolynomial[ <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ]
- Returns a randomly generated polynomial in x of degree at most d, whose (integer) coefficients are in the range from min to max, both included.
Example:
RandomPolynomial[0, 1, 2]
yields either 1 or 2 andRandomPolynomial[2, 1, 2]
yields a random polynomial with a degree of two and only 1 and 2 as coefficients, for example 2x2 + x + 1.
Note: The coefficient of x to the power of d is guaranteed not to be zero.
- RandomPolynomial[ <Variable Var>, <Degree d> , <Minimum for Coefficients min>, <Maximum for Coefficients max> ]
- Returns a randomly generated polynomial in Var of degree at most d, whose (integer) coefficients are in the range from min to max, both included.
- Note: In both cases if min or max are not integers, round(min) and round(max) are used instead.
- Note: The coefficient of Var to the power of d is guaranteed not to be zero.