 RandomExpand - Maple Help

RandomTools

 RandomExpand
 create a random expression 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

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{RandomExpand}\left(4\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%^}}{}\left({\mathrm{%+}}{}\left({-}{2}{,}{4}\right){,}{2}\right)\right]\right)$ (1)
 > $\mathrm{RandomExpand}\left(4,\mathrm{operations}=\left[\mathrm{^}\right]\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%^}}{}\left({2}{,}{2}\right)\right]\right)$ (2)
 > $\mathrm{RandomExpand}\left(4,\mathrm{operations}=\left[\mathrm{-},\mathrm{*},\mathrm{/}\right]\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%*}}{}\left({\mathrm{%/}}{}\left({6}{,}{3}\right){,}{2}\right)\right]\right)$ (3)
 > $\mathrm{RandomExpand}\left(4,\mathrm{operations}=\left[\mathrm{-},\mathrm{*},\mathrm{/}\right],\mathrm{numterms}=10\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%-}}{}\left({\mathrm{%-}}{}\left({\mathrm{%-}}{}\left({\mathrm{%-}}{}\left({6}{,}{\mathrm{%-}}{}\left({5}{,}{-}{5}\right)\right){,}{-}{3}\right){,}{\mathrm{%-}}{}\left({-}{1}{,}{-}{3}\right)\right){,}{\mathrm{%-}}{}\left({\mathrm{%-}}{}\left({6}{,}{7}\right){,}{\mathrm{%*}}{}\left({2}{,}{3}\right)\right)\right)\right]\right)$ (4)
 > $\mathrm{RandomExpand}\left(10{x}^{2},\mathrm{coeffs}=-100..0\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%-}}{}\left({\mathrm{%-}}{}\left({\mathrm{%*}}{}\left({\mathrm{%^}}{}\left({-}{3}{,}{3}\right){,}{{x}}^{{2}}\right){,}{-}{48}{}{{x}}^{{2}}\right){,}{11}{}{{x}}^{{2}}\right)\right]\right)$ (5)
 > $\mathrm{RandomExpand}\left(x+y,\mathrm{numterms}=10,\mathrm{operations}=\left[\mathrm{^},\mathrm{*}\right],\mathrm{exponent}=-100..100\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%+}}{}\left({\mathrm{%*}}{}\left({\mathrm{%^}}{}\left({-}{7}{,}{49}\right){,}{y}{,}{\mathrm{%^}}{}\left({-}{7}{,}{-}{49}\right)\right){,}{\mathrm{%*}}{}\left({x}{,}{\mathrm{%^}}{}\left({-}{6}{,}{11}\right){,}{\mathrm{%^}}{}\left({-}{6}{,}{-}{11}\right)\right)\right)\right]\right)$ (6)
 > $\mathrm{RandomExpand}\left(90,\mathrm{coeffs}=-100..100,\mathrm{exponent}=-100..100,\mathrm{operations}=\left[\mathrm{^},\mathrm{*}\right],\mathrm{numterms}=10\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%*}}{}\left({5}{,}{\mathrm{%^}}{}\left({2}{,}{-}{56}\right){,}{\mathrm{%^}}{}\left({2}{,}{57}\right){,}{\mathrm{%^}}{}\left({\mathrm{%*}}{}\left({3}{,}{1}\right){,}{\mathrm{%*}}{}\left({\mathrm{%^}}{}\left({2}{,}{61}\right){,}{\mathrm{%^}}{}\left({2}{,}{-}{60}\right)\right)\right)\right)\right]\right)$ (7)
 > $\mathrm{RandomExpand}\left(1,\mathrm{coeffs}=0..10,\mathrm{operations}=\left[\mathrm{+}\right],\mathrm{numterms}=2,\mathrm{allowzero}\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%+}}{}\left({1}{,}{0}\right)\right]\right)$ (8)
 > $\mathrm{RandomExpand}\left(x+y+z,\mathrm{numterms}=9,\mathrm{scramble}=\mathrm{false}\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%-}}{}\left({\mathrm{%^}}{}\left({-}{z}{,}{3}\right){}{\mathrm{%^}}{}\left({-}{1}{,}{0}\right){}{\mathrm{%^}}{}\left({z}{,}{-}{2}\right){,}{-}{2}{}{z}\right)\right]\right){+}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%-}}{}\left({\mathrm{%*}}{}\left({3}{,}\frac{{8}}{{3}}\right){}{x}{,}{7}{}{x}\right)\right]\right){+}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%/}}{}\left({6}{}{y}{,}{6}\right)\right]\right)$ (9)
 > $\mathrm{RandomExpand}\left(x+y+z,\mathrm{numterms}=9\right)$
 ${\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%+}}{}\left({\mathrm{%*}}{}\left({3}{,}{3}{,}{x}\right){,}{\mathrm{%*}}{}\left({y}{,}{\mathrm{%^}}{}\left({-}{2}{,}{3}\right)\right){,}{\mathrm{%/}}{}\left({10}{}{y}{,}{2}\right){,}{4}{}{y}{,}{\mathrm{%*}}{}\left({3}{,}{-}\frac{{8}}{{3}}{,}{x}\right){,}{5}{}{z}{,}{-}{4}{}{z}\right)\right]\right)$ (10) Compatibility

 • The RandomTools[RandomExpand] command was introduced in Maple 2018.