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

For example,
@itemize
@item
@code{ratp_coeffs(5*x^7-3*x^2+4,x)} returns @code{[[7,5],[2,-3],[0,4]]}, which omits zero terms;
@item
@code{ratp_dense_coeffs(5*x^7-y*x^2+4,x)} returns @code{[5,0,0,0,0,-y,0,4]}, which includes zero terms;
@item
@code{ratp_dense_coeffs((x^4-y^4)/(x-y),x)} returns @code{[1,y,y^2,y^3]},
because CRE simplifies the expression to @code{x^3+y*x^2+y^2*x+y^3};
@item
@code{ratp_dense_coeffs(x+sqrt(x),x)} returns @code{[1,sqrt(x)]}
while @code{ratp_dense_coeffs(x+sqrt(x),sqrt(x))} returns @code{[1,x]}:
in CRE form, @code{x} and @code{sqrt(x)} are treated as independent variables.
@end itemize

The returned coefficients are in CRE form except for numbers.

For the list of vars of a CRE polynomial, use @mref{showratvars}.
For the denominator of a CRE polynomial, use @mref{ratdenom}.

For information about CREs see also @mrefcomma{rat} @mref{ratdisrep} and
@mrefdot{showratvars}
@menu
* Functions and Variables for ratpow::
@end menu

@node Functions and Variables for ratpow, , , ratpow-pkg
@section Functions and Variables for ratpow



@anchor{ratp_hipow}
@deffn {Function} ratp_hipow (@var{expr}, @var{x})

Returns the highest power of @var{x} in @code{ratnumer(expr)}

@c ===beg===
@c load("ratpow")$
@c ratp_hipow( x^(5/2) + x^2 , x);
@c ratp_hipow( x^(5/2) + x^2 , sqrt(x));
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) ratp_hipow( x^(5/2) + x^2 , x);
(%o2)                           2
@end group
@group
(%i3) ratp_hipow( x^(5/2) + x^2 , sqrt(x));
(%o3)                           5
@end group
@end example

@opencatbox{Categories:}
@category{Rational expressions}
@category{Package ratpow}
@closecatbox
@end deffn


@anchor{ratp_lopow}
@deffn {Function} ratp_lopow (@var{expr}, @var{x})

Returns the lowest power of @var{x} in @code{ratnumer(expr)}

@c ===beg===
@c load("ratpow")$
@c ratp_lopow( x^5 + x^2 , x);
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) ratp_lopow( x^5 + x^2 , x);
(%o2)                           2
@end group
@end example

The following example returns 0 since @code{1} equals @code{x^0}:
@c ===beg===
@c load("ratpow")$
@c ratp_lopow( x^5 + x^2 + 1, x);
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) ratp_lopow( x^5 + x^2 + 1, x);
(%o2)                           0
@end group
@end example

The CRE form of the following equation contains @code{sqrt(x)} and
@code{x}. Since they are interpreted as independent variables,
@code{ratp_lopow} returns @code{0}:
@c ===beg===
@c load("ratpow")$
@c g:sqrt(x)^5 + sqrt(x)^2;
@c showratvars(g);
@c ratp_lopow( g, x);
@c ratp_lopow( g, sqrt(x));
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) g:sqrt(x)^5 + sqrt(x)^2;
                             5/2
(%o2)                       x    + x
@end group
@group
(%i3) showratvars(g);
                              1/2
(%o3)                       [x   , x]
@end group
@group
(%i4) ratp_lopow( g, x);
(%o4)                           0
@end group
@group
(%i5) ratp_lopow( g, sqrt(x));
(%o5)                           0
@end group
@end example


@opencatbox{Categories:}
@category{Rational expressions}
@category{Package ratpow}
@closecatbox
@end deffn


@anchor{ratp_coeffs}
@deffn {Function} ratp_coeffs (@var{expr}, @var{x})

Returns the powers and coefficients of @var{x} in @code{ratnumer(expr)} as a list of length-2 lists;
returned coefficients are in CRE form except for numbers.


@code{ratnumer(expr)}.
@c ===beg===
@c load("ratpow")$
@c ratp_coeffs( 4*x^3 + x + sqrt(x), x);
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) ratp_coeffs( 4*x^3 + x + sqrt(x), x);
(%o2)/R/         [[3, 4], [1, 1], [0, sqrt(x)]]
@end group
@end example
@opencatbox{Categories:}
@category{Rational expressions}
@category{Package ratpow}
@closecatbox
@end deffn

@anchor{ratp_dense_coeffs}
@deffn {Function} ratp_dense_coeffs (@var{expr}, @var{x})

Returns the coefficients of powers of @var{x} in @code{ratnumer(expr)} from highest to lowest;
returned coefficients are in CRE form except for numbers.

@c ===beg===
@c load("ratpow")$
@c ratp_dense_coeffs( 4*x^3 + x + sqrt(x), x);
@c ===end===
@example
(%i1) load("ratpow")$
@group
(%i2) ratp_dense_coeffs( 4*x^3 + x + sqrt(x), x);
(%o2)/R/               [4, 0, 1, sqrt(x)]
@end group
@end example

@opencatbox{Categories:}
@category{Rational expressions}
@category{Package ratpow}
@closecatbox
@end deffn

