REDUCE

9.11 Obtaining Parts of Polynomials and Rationals

These operators select various parts of a polynomial or rational function structure. Except for the cost of rearrangement of the structure, these operations take very little time to perform.

For those operators in this section that take a kernel var as their second argument, an error results if the first expression is not a polynomial in var, although the coefficients themselves can be rational as long as they do not depend on var. However, if the switch ratarg is on, denominators are not checked for dependence on var, and are taken to be part of the coefficients.

9.11.1 DEG Operator

This operator is used with the syntax

        deg(exprn:polynomial,var:kernel):integer.

It returns the leading degree of the polynomial exprn in the variable var. If var does not occur as a variable in exprn, 0 is returned.

Examples:

        deg((a+b)*(c+2*d)^2,a) ->  1
        deg((a+b)*(c+2*d)^2,d) ->  2
        deg((a+b)*(c+2*d)^2,e) ->  0.

Note also that if ratarg is on,

        deg((a+b)^3/a,a)       ->  3

since in this case, the denominator a is considered part of the coefficients of the numerator in a. With ratarg off, however, an error would result in this case.

9.11.2 DEN Operator

This is used with the syntax:

        den(exprn:rational):polynomial.

It returns the denominator of the rational expression exprn. If exprn is a polynomial, 1 is returned.

Examples:

        den(x/y^2)   ->  Y**2
        den(100/6)   ->  3
             % since 100/6 is first simplified to 50/3
        den(a/4+b/6) ->  12
        den(a+b)     ->  1

9.11.3 LCOF Operator

lcof is used with the syntax

        lcof(exprn:polynomial,var:kernel):polynomial.

It returns the leading coefficient of the polynomial exprn in the variable var. If var does not occur as a variable in exprn, exprn is returned. Examples:

        lcof((a+b)*(c+2*d)^2,a) ->  c**2+4*c*d+4*d**2
        lcof((a+b)*(c+2*d)^2,d) ->  4*(a+b)
        lcof((a+b)*(c+2*d),e)   ->  a*c+2*a*d+b*c+2*b*d

9.11.4 LPOWER Operator

Syntax:

        lpower(exprn:polynomial,var:kernel):polynomial.

lpower returns the leading power of exprn with respect to var. If exprn does not depend on var, 1 is returned.

Examples:

        lpower((a+b)*(c+2*d)^2,a) ->  a
        lpower((a+b)*(c+2*d)^2,d) ->  d**2
        lpower((a+b)*(c+2*d),e)   ->  1

9.11.5 LTERM Operator

Syntax:

        lterm(exprn:polynomial,var:kernel):polynomial.

lterm returns the leading term of exprn with respect to var. If exprn does not depend on var, exprn is returned.

Examples:

    lterm((a+b)*(c+2*d)^2,a) ->  a*(c**2+4*c*d+4*d**2)
    lterm((a+b)*(c+2*d)^2,d) ->  4*d**2*(a+b)
    lterm((a+b)*(c+2*d),e)   ->  a*c+2*a*d+b*c+2*b*d

Compatibility Note:  In some earlier versions of REDUCE, lterm returned 0 if the exprn did not depend on var. In the present version, exprn is always equal to lterm(exprn,var) + reduct(exprn,var).

9.11.6 MAINVAR Operator

Syntax:

        mainvar(exprn:polynomial):expression.

Returns the main variable (based on the internal polynomial representation) of exprn. If exprn is a domain element, 0 is returned.

Examples:

Assuming a has higher kernel order than b, c, or d:

        mainvar((a+b)*(c+2*d)^2) ->  a
        mainvar(2)               ->  0

9.11.7 NUM Operator

Syntax:

        num(exprn:rational):polynomial.

Returns the numerator of the rational expression exprn. If exprn is a polynomial, that polynomial is returned.

Examples:

        num(x/y^2)  ->  x
        num(100/6)   ->  50
        num(a/4+b/6) ->  3*a+2*b
        num(a+b)     ->  a+b

9.11.8 REDUCT Operator

Syntax:

        reduct(exprn:polynomial,var:kernel):polynomial.

Returns the reductum of exprn with respect to var (i.e., the part of exprn left after the leading term is removed). If exprn does not depend on the variable var, 0 is returned.

Examples:

     reduct((a+b)*(c+2*d),a) ->  b*(c + 2*d)
     reduct((a+b)*(c+2*d),d) ->  c*(a + b)
     reduct((a+b)*(c+2*d),e) ->  0

Compatibility Note:  In some earlier versions of REDUCE, reduct returned exprn if it did not depend on var. In the present version, exprn is always equal to lterm(exprn,var) + reduct(exprn,var).

9.11.9 TOTALDEG Operator

Syntax:

     totaldeg(a*x^2+b*x+c, x)  => 2
     totaldeg(a*x^2+b*x+c, {a,b,c})  => 1
     totaldeg(a*x^2+b*x+c, {x, a})  => 3
     totaldeg(a*x^2+b*x+c, {x,b})  => 2
     totaldeg(a*x^2+b*x+c, {p,q,r})  => 0

totaldeg(u, kernlist) finds the total degree of the polynomial u in the variables in kernlist. If kernlist is not a list it is treated as a simple single variable. The denominator of u is ignored, and "degree" here does not pay attention to fractional powers. Mentions of a kernel within the argument to any operator or function (eg sin, cos, log, sqrt) are ignored. Really u is expected to be just a polynomial.


Hosted by Download REDUCE Powered by MathJax