Previous Page Next Page Contents

rationalize -- transform an expression into a rational expression

Introduction

rationalize(object) transforms the expression object into an equivalent rational expression by replacing non-rational subexpressions by newly generated variables.

Call(s)

rationalize(object, <, inspect <, stop>>)

Parameters

object - an arithmetical expression or a set or list of such expressions
inspect - subexpressions to operate on: a set of types, or a procedure, or NIL. The default is NIL, i.e., all subexpressions are to be inspected.
stop - subexpressions to be leaft unchanged: a set of types, or a procedure, or NIL. The default is the set {DOM_INT, DOM_RAT, DOM_IDENT}, i.e., integers, rational numbers and identifiers are not replaced by variables.

Returns

a sequence consisting of the rationalized object and a set of substitution equations.

Related Functions

indets, maprat, rewrite, simplify, subs

Details

Example 1

rationalize operates on single arithmetical expressions as well as on lists and sets of expressions:

>> rationalize(2*sqrt(3) + 0.5*x^3)
                               3                   1/2
                    2 D2 + D1 x , {D1 = 0.5, D2 = 3   }
>> rationalize([(x - sqrt(2))*(x^2 + sqrt(3)),
                (x - sqrt(2))*(x - sqrt(3))])
                       2                              1/2        1/2
      [(x - D3) (D4 + x ), (x - D3) (x - D4)], {D3 = 2   , D4 = 3   }

Example 2

rationalize allows to specify which kinds of subexpressions are to be inspected and which kinds of subexpressions are to be leaft unchanged. In the following call, the subexpression x^3 (of type "_power") is not inspected and replaced by a variable:

>> rationalize(2*sqrt(3) + 0.5*x^3, {"_plus", "_mult"})
                                    3                  1/2
               2 D5 + D6 D7, {D6 = x , D7 = 0.5, D5 = 3   }

In the following call, all subexpressions are inspected. Neither floating point numbers nor integers nor identifiers are replaced:

>> rationalize(2*sqrt(3) + 0.5*x^3, NIL, 
               {DOM_FLOAT, DOM_INT, DOM_IDENT})
                                    3         1/2
                        2 D8 + 0.5 x , {D8 = 3   }

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000