maprat
Apply a function to a rationalized expression
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
maprat(object
, f
, options
)
As a first step, maprat(object, f, options)
calls rationalize(object,
options)
, which generates a rational expression. The maprat
function
uses the expression returned by rationalize
as an input to the function f
.
As a second step, maprat
replaces all variables
generated by rationalize
with
the original subexpressions in object
.
See the rationalize
help
page for details.
Find the greatest common divisor (the gcd
function) for the following two rationalized
expressions. The first argument of maprat
is a
sequence of the two expressions p
, q
,
which gcd
takes
as two parameters. Note the brackets around the sequence p,
q
:
p := (x  sqrt(2))*(x^2 + sqrt(3)*x  1): q := (x  sqrt(2))*(x  sqrt(3)): maprat((p, q), gcd)
The maprat
function accepts the same options
as the rationalize
function.
For example, find the least common multiple (the lcm
function) for the following two rationalized
expressions. Use the FindRelations
option to detect
trigonometric relations:
p := tan(x)^2 + 1/cos(x)^2: q := 1/sin(x)^4 + cot(x)^4: maprat((p, q), lcm, FindRelations = ["sin"])
Without this option, the result is:
p := tan(x)^2 + 1/cos(x)^2: q := 1/sin(x)^4 + cot(x)^4: maprat((p, q), lcm)
Free the variables for further calculations:
delete p, q:

An arithmetical expression, or a sequence, or a set, or a list of such expressions 

A procedure or a functional expression 

Approximate floatingpoint numbers by rational numbers. 

Detect algebraic dependencies for subexpressions of specified types. 

If the original expression contains subexpressions, rationalize the specified types of subexpressions. 

Replace all subexpressions with limits, sums, and integrals by variables. 

Replace all subexpressions of the specified types by variables. 

Do not rationalize specified types of subexpressions. 

Do not rationalize numbers, strings, Boolean constants, 
Object returned by the function f
.