Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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.

Syntax

maprat(object, f, options)

Description

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.

Examples

Example 1

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)

Example 2

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:

Parameters

object

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

f

A procedure or a functional expression

Options

ApproximateFloats

Approximate floating-point numbers by rational numbers.

FindRelations

Detect algebraic dependencies for subexpressions of specified types.

DescendInto

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

ReplaceHardToEval

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

ReplaceTypes

Replace all subexpressions of the specified types by variables.

StopOn

Do not rationalize specified types of subexpressions.

StopOnConstants

Do not rationalize numbers, strings, Boolean constants, NIL, FAIL, PI, EULER, and CATALAN in the set Type::ConstantIdents.

Return Values

Object returned by the function f.

See Also

MuPAD Functions

Was this topic helpful?