RandomTools
RandomExpand
create a random expression
Calling Sequence
Parameters
Description
Examples
Compatibility
RandomExpand( expr )
expr
-
integer, polynomial, general expression
operations
{list,set} containing any of +, *, -, ^, /
coeffs
integer .. integer range
exponent
numterms
positive integer
allowzero
truefalse
scramble
The RandomExpand command produces a new expression in "expanded" form that is equivalent to the given expr.
To avoid simplification, the output of this command uses % inert form operators. For example, RandomExpand(4) could produce 2 %+ 2. The standard interface will display this expression with a grey plus symbol. The value command can be used to turn the inert form back into standard form, which will evaluate and incur simplification, turning it back into 4.
The operations option by default includes all arithmetic operations, [`+`,`*`, `-`, `^`, `/`]. Specify a subset of these operations in order to limit the kind of expansions that will be applied. For example, RandomExpand(4,operations=[*]) will find 2 %* 2, but not generate 2 %+ 2 because + is omitted from the list of expansions.
Expansions involving ^ may also include * whether or not times is included as part of the operations list.
The coeffs option specifies the range of integer coefficients that will be used in the expansion. Numbers outside this range may be present in the generated expression if the original expr started with coefficients outside the specified range. Restricting the coeffs range too tightly might cause the command to be unable to generate equivalent expressions; in which case the original expression may be returned, or fewer than numterms generated. The default is coeffs = -10..10.
The exponent option specifies the range of integers that can be used in formulating integer exponents. This is distinct from the case of expanding an expression like x^y, where both x and y can be expanded using the coeffs range. The default is exponent = 1..3.
The numterms option gives a target for the number of additional terms in the result expression. No more than numterms+2 new terms will be introduced into the result expression. The bound accommodates a single expansion that introduces multiple terms at once. Bound restrictions and initial input can restrict the result to less than numterms, including cases where the original expression is returned without change. The default is numterms = 3.
The allowzero option controls whether or not to allow zero terms in the expansion, such as 4 = 0 %+ 4. The default is allowzero = false.
The scramble option enables a final step in which terms are randomly reordered. The default is scramble = true.
with⁡RandomTools:
RandomExpand⁡4
−2+42
RandomExpand⁡4,operations=`^`
22
RandomExpand⁡4,operations=`-`,`*`,`/`
63∗2
RandomExpand⁡4,operations=`-`,`*`,`/`,numterms=10
6−5−−5−−3−−1−−3−6−7−2∗3
RandomExpand⁡10⁢x2,coeffs=−100..0
−33∗x2−−48⁢x2−11⁢x2
RandomExpand⁡x+y,numterms=10,operations=`^`,`*`,exponent=−100..100
−749∗y∗−7−49+x∗−611∗−6−11
RandomExpand⁡90,coeffs=−100..100,exponent=−100..100,operations=`^`,`*`,numterms=10
5∗2−56∗257∗3∗1261∗2−60
RandomExpand⁡1,coeffs=0..10,operations=`+`,numterms=2,allowzero
1+0
RandomExpand⁡x+y+z,numterms=9,scramble=false
−z3⁢−10⁢z−2−−2⁢z+3∗83⁢x−7⁢x+6⁢y6
RandomExpand⁡x+y+z,numterms=9
3∗3∗x+y∗−23+10⁢y2+4⁢y+3∗−83∗x+5⁢z−4⁢z
The RandomTools[RandomExpand] command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
HowDoI,WorkWithRandomGenerators
InertForm
rand
RandomTools[Generate]
randpoly
Download Help Document