frontend - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Algebra : Rational Expressions : frontend

frontend

process general expression into a rational expression

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Calling Sequence

frontend(p, x)

frontend(p, x, [ts, es], arg1,..., argn)

Parameters

p

-

procedure

x

-

list of arguments to p

ts

-

(optional) set of types of subexpressions that are not frozen (default: {`+`, `*`})

es

-

(optional) set of subexpressions e such that any subexpression containing e is not frozen (default: {})

argi

-

(optional) additional arguments to p; these arguments are not frozen

Description

• 

The purpose of frontend is to extend the domain of computation for many of the functions in Maple.

• 

For example, the procedure used by the Maple normal function is defined to work over the domain of rational functions.  Thus, to handle more general expressions such as expressions involving sinx or x reasonably, frontend is used to temporarily freeze all occurrences of such expressions for unique names.  This is always valid.

• 

However, it is important to understand that the zero equivalence property of the normal function is only guaranteed if the subexpressions that are frozen are algebraically independent.

• 

For each item in the list x, the following algorithm is applied to determine whether it or any of its subexpressions are frozen:

– 

The following are not frozen: integers; rationals; floats that are of type numeric; strings; and names that are not of type constant.

– 

If the argument is one of the expressions in es, then neither it nor its subexpressions is frozen.

– 

If the argument

• 

is of one of the types in ts (`+` and `*` by default), or

• 

is of type `^` and the exponent is an integer, or

• 

contains one of the expressions in es, as determined by has,

  

then it is not frozen and the algorithm is applied recursively to its subexpressions to determine if they or their subexpressions are frozen.

– 

Otherwise, the argument is frozen. That is, a unique name is substituted for it.

• 

The procedure p is then evaluated with the frozen argument(s). Any frozen names occurring in the result are substituted back for their original subexpressions.

• 

The frontend function does not work with functions that assign a value to the function argument(s). For example, gcdex works but not if you specify the optional arguments.

Thread Safety

• 

The frontend command is thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

Suppose we want to find out the maximum degree to which the variable x occurs in the expression a, ignoring cases where x is inside a non-polynomial function.

asinx+x2

asinx+x2

(1)

The default command to use for this is degree, but it requires that its argument is a polynomial. The expression a is not a polynomial because of the occurrence of sinx, so straightforward application of the degree command will fail.

degreea,x

FAIL

(2)

Using frontend freezes the sine function. As a consequence, degree now succeeds: all it sees is a polynomial.

frontenddegree,a,x

2

(3)

Here is another example. Suppose we want to expand the square in the following expression b.

bsinx+y+sinxy2

bsinx+y+sinxy2

(4)

Straightforward application of the expand command also expands the trigonometric expressions, which we may not want to happen.

expandb

4sinx2cosy2

(5)

If we apply frontend, it freezes the trigonometric expressions. The expand command then sees something of the form s1+s22 and expands it to s12+2s1s2+s22, not knowing or caring that s1 represents sinx+y and s2 represents sinxy. Afterwards, frontend substitutes the original trigonometric expressions for the variables.

frontendexpand,b

sinx+y2+2sinx+ysinxy+sinxy2

(6)

In the final example, we use the indets command to find the indeterminates in the expression c. We examine several variations of how to call indets to get various results.

cx+siny+cos1+ⅇcos1z

cx+siny+cos1+ⅇcos1z

(7)

By default, indets returns all subexpressions of c that are not sums, products, or constants.

indetsc

x,y,z,x,ⅇcos1z,siny

(8)

Let's examine what frontend does to c. We can do this with the following frontend call, in which we use print for the procedure p:

frontendprint,c

O+O+O+O

(9)

We see that frontend replaces each of the four terms with a (new) variable called O. This means that in the following call, indets simply sees a sum of four variables, and returns these variables. frontend then replaces the original four terms for them.

frontendindets,c

x,cos1,ⅇcos1z,siny

(10)

If we specify that frontend should not freeze any subexpressions of type radical, then x will not be frozen. Let's examine this again by using print as the procedure p.

frontendprint,c,`+`,`*`,radical

x+O+O+O

(11)

This means that in the following call, indets sees the unfrozen expression x plus three variables O. It returns the three Os, x, and x itself. Then frontend substitutes the three original other terms for the Os and returns the result, as follows:

frontendindets,c,`+`,`*`,radical

x,x,cos1,ⅇcos1z,siny

(12)

Finally, in the following call, we specify that frontend should not freeze any subexpressions that contain the expression cos1. This means the term cos1 by itself, but also the term ⅇcos1z.

frontendprint,c,`+`,`*`,cos1

O+O+cos1+ⅇcos1z

(13)

Consequently, in the corresponding indets call, the expressions x and siny are frozen as new variables O, and indets can not look inside the expressions to find the separate variables x and y. It does, however, see the expression cos1, and it recognizes it as a constant that is not to be included in the set of indeterminates. It also sees the variable z, which is also returned.

frontendindets,c,`+`,`*`,cos1

z,x,ⅇcos1z,siny

(14)

See Also

freeze