RandomTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Random Objects : RandomTools package : Commands : RandomTools/RandomExpand

RandomTools

  

RandomExpand

  

create a random expression

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

RandomExpand( expr )

Parameters

expr

-

integer, polynomial, general expression

operations

-

{list,set} containing any of +, *, -, ^, / 

coeffs

-

integer .. integer range

exponent

-

integer .. integer range

numterms

-

positive integer

allowzero

-

truefalse

scramble

-

truefalse

Description

• 

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.

Examples

withRandomTools:

RandomExpand4

?

(1)

RandomExpand4,operations=`^`

?

(2)

RandomExpand4,operations=`-`,`*`,`/`

?

(3)

RandomExpand4,operations=`-`,`*`,`/`,numterms=10

?

(4)

RandomExpand10x2,coeffs=100..0

?

(5)

RandomExpandx+y,numterms=10,operations=`^`,`*`,exponent=100..100

?

(6)

RandomExpand90,coeffs=100..100,exponent=100..100,operations=`^`,`*`,numterms=10

?

(7)

RandomExpand1,coeffs=0..10,operations=`+`,numterms=2,allowzero

?

(8)

RandomExpandx+y+z,numterms=9,scramble=false

?+?+?

(9)

RandomExpandx+y+z,numterms=9

?

(10)

Compatibility

• 

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

RandomTools[Generate]

randpoly