RandomTools
GenerateSimilar
create a random expression similar to the one given
Calling Sequence
Parameters
Description
Examples
Compatibility
GenerateSimilar( expr )
expr
-
integer, float, polynomial, or general expression
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.
with⁡RandomTools:
GenerateSimilar⁡x
4⁢x+2
The cube on the sin function is preserved.
GenerateSimilar⁡sin⁡x3+3⁢ⅇx2
−5⁢Typesetting:-_Hold⁡%cos⁡x−73−5⁢Typesetting:-_Hold⁡%exp⁡−4⁢x2+3⁢x
Inputting a factorable polynomial returns a factorable polynomial..
factor⁡r2+r−6
r+3⁢r−2
poly1 ≔ GenerateSimilar⁡r2+r−6
poly1≔r2−6⁢r−16
factor⁡poly1
r+2⁢r−8
A polynomial without integer roots returns a polynomial with random coefficients
solve⁡r2−2⁢r+2=0
1+I,1−I
GenerateSimilar⁡r2−2⁢r+2
r2+r+2
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.
factor⁡y2−1y−3
y−1⁢y+1y−3
rational1 ≔ GenerateSimilar⁡y2−1y−3
rational1≔−y2+4⁢y−3−y−4
factor⁡rational1
y−1⁢y−3y+4
factor⁡y2−1y+1
y−1
rational2 ≔ GenerateSimilar⁡y2−1y+1
rational2≔−y2+11⁢y−24−y+3
factor⁡rational2
y−8
Singular matrices return singular matrices.
with⁡LinearAlgebra:
Determinant⁡Matrix⁡3,3,2,4,6,2,0,2,6,8