Difference between revisions of "RandomPolynomial Command"
From GeoGebra Manual
Line 1: | Line 1: | ||
<noinclude>{{Manual Page|version=4.2}}[[Category:Manual (official)|{{PAGENAME}}]]</noinclude> | <noinclude>{{Manual Page|version=4.2}}[[Category:Manual (official)|{{PAGENAME}}]]</noinclude> | ||
{{command|probability}} | {{command|probability}} | ||
− | ;RandomPolynomial[ <Degree | + | ;RandomPolynomial[ <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ] |
− | :Returns a randomly generated polynomial in ''x'' of degree ''d'', whose (integer) coefficients are in the range from '' | + | :Returns a randomly generated polynomial in ''x'' of degree ''d'', whose (integer) coefficients are in the range from ''minimum'' to ''maximum'', both included. |
:{{Examples|1=<div> | :{{Examples|1=<div> | ||
:*<code><nowiki>RandomPolynomial[0, 1, 2]</nowiki></code> yields either ''1'' or ''2'' and | :*<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 + 1''.</div>}} | :*<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 + 1''.</div>}} | ||
==CAS Syntax== | ==CAS Syntax== | ||
− | ;RandomPolynomial[ <Degree | + | ;RandomPolynomial[ <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ] |
− | :Returns a randomly generated polynomial in ''x'' of degree ''d'', whose (integer) coefficients are in the range from '' | + | :Returns a randomly generated polynomial in ''x'' of degree ''d'', whose (integer) coefficients are in the range from ''minimum'' to ''maximum'', both included. |
:{{Examples|1=<div> | :{{Examples|1=<div> | ||
:*<code><nowiki>RandomPolynomial[0, 1, 2]</nowiki></code> yields either ''1'' or ''2'' and | :*<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 + 1''.</div>}} | :*<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 + 1''.</div>}} | ||
− | ;RandomPolynomial[ <Variable | + | ;RandomPolynomial[ <Variable>, <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ] |
− | :Returns a randomly generated polynomial in '' | + | :Returns a randomly generated polynomial in ''Variable'' of degree ''d'', whose (integer) coefficients are in the range from ''minimum'' to ''maximum'', both included. |
:{{Examples|1=<div> | :{{Examples|1=<div> | ||
:*<code><nowiki>RandomPolynomial[a, 0, 1, 2]</nowiki></code> yields either ''1'' or ''2'' and | :*<code><nowiki>RandomPolynomial[a, 0, 1, 2]</nowiki></code> yields either ''1'' or ''2'' and | ||
:*<code><nowiki>RandomPolynomial[a, 2, 1, 2]</nowiki></code> yields a random polynomial with a degree of two and only ''1'' and ''2'' as coefficients, for example ''2a<sup>2</sup> + a + 1''.</div>}} | :*<code><nowiki>RandomPolynomial[a, 2, 1, 2]</nowiki></code> yields a random polynomial with a degree of two and only ''1'' and ''2'' as coefficients, for example ''2a<sup>2</sup> + a + 1''.</div>}} | ||
− | {{Note|1=In both cases if '' | + | {{Note|1=In both cases if ''minimum'' or ''maximum'' are not integers, ''round(minimum)'' and ''round(maximum)'' are used instead.}} |
Revision as of 12:44, 15 July 2013
- RandomPolynomial[ <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ]
- Returns a randomly generated polynomial in x of degree d, whose (integer) coefficients are in the range from minimum to maximum, both included.
- Examples:
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.
CAS Syntax
- RandomPolynomial[ <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ]
- Returns a randomly generated polynomial in x of degree d, whose (integer) coefficients are in the range from minimum to maximum, both included.
- Examples:
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.
- RandomPolynomial[ <Variable>, <Degree> , <Minimum for Coefficients>, <Maximum for Coefficients> ]
- Returns a randomly generated polynomial in Variable of degree d, whose (integer) coefficients are in the range from minimum to maximum, both included.
- Examples:
RandomPolynomial[a, 0, 1, 2]
yields either 1 or 2 andRandomPolynomial[a, 2, 1, 2]
yields a random polynomial with a degree of two and only 1 and 2 as coefficients, for example 2a2 + a + 1.
Note: In both cases if minimum or maximum are not integers, round(minimum) and round(maximum) are used instead.