The package ratpow provides functions that return the coefficients of the numerator of a CRE polynomial in a given variable.

For example,

  * ratp_coeffs(5*x^7-3*x^2+4,x) returns [[7,5],[2,-3],[0,4]], which omits zero terms;

  * ratp_dense_coeffs(5*x^7-y*x^2+4,x) returns [5,0,0,0,0,-y,0,4], which includes zero terms;

  * ratp_dense_coeffs((x^4-y^4)/(x-y),x) returns [1,y,y^2,y^3], because CRE simplifies the expression to x^3+y*x^2+y^2*x+y^3;

  * ratp_dense_coeffs(x+sqrt(x),x) returns [1,sqrt(x)] while ratp_dense_coeffs(x+sqrt(x),sqrt(x)) returns [1,x]: in CRE form, x and sqrt(x) are treated as independent variables.

The returned coefficients are in CRE form except for numbers.

For the list of vars of a CRE polynomial, use showratvars. For the denominator of a CRE polynomial, use ratdenom.

For information about CREs see also rat ratdisrep and showratvars

Functions and Variables for ratpow
==================================

 -- Function: ratp_hipow (EXPR, X)

     Returns the highest power of X in ratnumer(expr)

          (%i1) load("ratpow")$

          (%i2) ratp_hipow( x^(5/2) + x^2 , x);
          (%o2)                           2

          (%i3) ratp_hipow( x^(5/2) + x^2 , sqrt(x));
          (%o3)                           5

     Categories: Rational expressions Package ratpow

 -- Function: ratp_lopow (EXPR, X)

     Returns the lowest power of X in ratnumer(expr)

          (%i1) load("ratpow")$

          (%i2) ratp_lopow( x^5 + x^2 , x);
          (%o2)                           2

     The following example returns 0 since 1 equals x^0:

          (%i1) load("ratpow")$

          (%i2) ratp_lopow( x^5 + x^2 + 1, x);
          (%o2)                           0

     The CRE form of the following equation contains sqrt(x) and x. Since they are interpreted as independent variables, ratp_lopow returns 0:

          (%i1) load("ratpow")$

          (%i2) g:sqrt(x)^5 + sqrt(x)^2;
                                       5/2
          (%o2)                       x    + x

          (%i3) showratvars(g);
                                        1/2
          (%o3)                       [x   , x]

          (%i4) ratp_lopow( g, x);
          (%o4)                           0

          (%i5) ratp_lopow( g, sqrt(x));
          (%o5)                           0

     Categories: Rational expressions Package ratpow

 -- Function: ratp_coeffs (EXPR, X)

     Returns the powers and coefficients of X in ratnumer(expr) as a list of length-2 lists; returned coefficients are in CRE form except for numbers.

     ratnumer(expr).

          (%i1) load("ratpow")$

          (%i2) ratp_coeffs( 4*x^3 + x + sqrt(x), x);
          (%o2)/R/         [[3, 4], [1, 1], [0, sqrt(x)]]

     Categories: Rational expressions Package ratpow

 -- Function: ratp_dense_coeffs (EXPR, X)

     Returns the coefficients of powers of X in ratnumer(expr) from highest to lowest; returned coefficients are in CRE form except for numbers.

          (%i1) load("ratpow")$

          (%i2) ratp_dense_coeffs( 4*x^3 + x + sqrt(x), x);
          (%o2)/R/               [4, 0, 1, sqrt(x)]

     Categories: Rational expressions Package ratpow