 GenerateSimilar - Maple Help

RandomTools

 GenerateSimilar
 create a random expression similar to the one given Calling Sequence GenerateSimilar( expr ) Parameters

 expr - integer, float, polynomial, or general expression Description

 • The GenerateSimilar command produces a new expression that is similar to the given expression expr. The structure and variables in the original expression are preserved, but new constants and coefficients replace the initial ones. The random floating-point numbers and integers in the new expression are the same magnitude as in the original.
 • Trig functions are not always preserved: sin and cos can switch, sec and csc can switch, and tan and cot can switch. The inverse trig functions are paired and can switch in the same way.
 • Inputting a polynomial that can be factored and has integer roots returns a polynomial of the same order that can be factored and has integer roots.
 • If a polynomial is input without integer roots then a polynomial up to the same degree as the input polynomial with random coefficients up to the same order of magnitude as the largest integer in the input expression is returned.
 • Numerators and denominators of input rational expressions are replaced in the same way as polynomials with the additional feature that if the numerator and denominator have a common root then the returned rational expression also has a shared root in its numerator and denominator.
 • If a singular square matrix is input then a singular square matrix is output. Inputting upper triangular, lower triangular, diagonal, symmetric, hermitian, or antisymmetric matrices returns the same type. Otherwise the elements of the output matrix are generated individually from each element of the input matrix.
 • Rational and integer exponents of functions or expressions (other than exponential functions) are preserved.
 • If an integral is passed into the function then the resultant integral will be solvable using the same integration technique (u substitution, partial fractions, trig substitution, integration by parts).
 • If an equation is passed into GenerateSimilar then a similar equation is output: radical equations produce radical equations, polynomial equations produce polynomial equations, logarithmic equations produce logarithmic equations, and exponential equations produce exponential equations.
 • Sums over values of binomial or poisson probability distributions produce sums over values of binomial or poisson probability distributions respectively.
 • Expectation value of a function over a binomial or poisson probability distribution returns an expectation value of a similar function over a binomial or poisson probability distribution respectively.
 • Integrals over values of exponential or gaussian probability distributions return integrals over values of exponential or gaussian probability distributions respectively.
 • Expectation value of a function over an exponential or gaussian probability distribution returns an expectation value of a similar function over an exponential or gaussian probability distribution respectively.
 • Parametrizations of circles, ellipses and cycloids return parametrizations of circles, ellipses and cycloids.
 • Differential equations should not be input into GenerateSimilar; for differential equations use GenerateSimilarODE. Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{GenerateSimilar}\left(x\right)$
 ${4}{}{x}{+}{2}$ (1)

The cube on the sin function is preserved.

 > $\mathrm{GenerateSimilar}\left({\mathrm{sin}\left(x\right)}^{3}+3\mathrm{exp}\left({x}^{2}\right)\right)$
 ${-}{5}{}{{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%cos}}{}\left({x}{-}{7}\right)\right]\right)}^{{3}}{-}{5}{}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%exp}}{}\left({-}{4}{}{{x}}^{{2}}{+}{3}{}{x}\right)\right]\right)$ (2)

Inputting a factorable polynomial returns a factorable polynomial..

 > $\mathrm{factor}\left({r}^{2}+r-6\right)$
 $\left({r}{+}{3}\right){}\left({r}{-}{2}\right)$ (3)
 > $\mathrm{poly1}≔\mathrm{GenerateSimilar}\left({r}^{2}+r-6\right)$
 ${\mathrm{poly1}}{≔}{{r}}^{{2}}{-}{6}{}{r}{-}{16}$ (4)
 > $\mathrm{factor}\left(\mathrm{poly1}\right)$
 $\left({r}{+}{2}\right){}\left({r}{-}{8}\right)$ (5)

A polynomial without integer roots returns a polynomial with random coefficients

 > $\mathrm{solve}\left({r}^{2}-2r+2=0\right)$
 ${1}{+}{I}{,}{1}{-}{I}$ (6)
 > $\mathrm{GenerateSimilar}\left({r}^{2}-2r+2\right)$
 ${{r}}^{{2}}{+}{r}{+}{2}$ (7)

Factorable numerators and denominators remain factorable and if a factor is shared between the numerator and denominator then the resultant rational function will share a factor between numerator and denominator.

 > $\mathrm{factor}\left(\frac{{y}^{2}-1}{y-3}\right)$
 $\frac{\left({y}{-}{1}\right){}\left({y}{+}{1}\right)}{{y}{-}{3}}$ (8)
 > $\mathrm{rational1}≔\mathrm{GenerateSimilar}\left(\frac{{y}^{2}-1}{y-3}\right)$
 ${\mathrm{rational1}}{≔}\frac{{-}{{y}}^{{2}}{+}{4}{}{y}{-}{3}}{{-}{y}{-}{4}}$ (9)
 > $\mathrm{factor}\left(\mathrm{rational1}\right)$
 $\frac{\left({y}{-}{1}\right){}\left({y}{-}{3}\right)}{{y}{+}{4}}$ (10)
 > $\mathrm{factor}\left(\frac{{y}^{2}-1}{y+1}\right)$
 ${y}{-}{1}$ (11)
 >