1 The package @code{ratpow} provides functions that return the coefficients
2 of the numerator of a CRE polynomial in a given variable.
7 @code{ratp_coeffs(5*x^7-3*x^2+4,x)} returns @code{[[7,5],[2,-3],[0,4]]}, which omits zero terms;
9 @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;
11 @code{ratp_dense_coeffs((x^4-y^4)/(x-y),x)} returns @code{[1,y,y^2,y^3]},
12 because CRE simplifies the expression to @code{x^3+y*x^2+y^2*x+y^3};
14 @code{ratp_dense_coeffs(x+sqrt(x),x)} returns @code{[1,sqrt(x)]}
15 while @code{ratp_dense_coeffs(x+sqrt(x),sqrt(x))} returns @code{[1,x]}:
16 in CRE form, @code{x} and @code{sqrt(x)} are treated as independent variables.
19 The returned coefficients are in CRE form except for numbers.
21 For the list of vars of a CRE polynomial, use @mref{showratvars}.
22 For the denominator of a CRE polynomial, use @mref{ratdenom}.
24 For information about CREs see also @mrefcomma{rat} @mref{ratdisrep} and
27 * Functions and Variables for ratpow::
30 @node Functions and Variables for ratpow, , , Package ratpow
31 @section Functions and Variables for ratpow
36 @deffn {Function} ratp_hipow (@var{expr}, @var{x})
38 Returns the highest power of @var{x} in @code{ratnumer(expr)}
42 @c ratp_hipow( x^(5/2) + x^2 , x);
43 @c ratp_hipow( x^(5/2) + x^2 , sqrt(x));
48 (%i2) ratp_hipow( x^(5/2) + x^2 , x);
52 (%i3) ratp_hipow( x^(5/2) + x^2 , sqrt(x));
57 @opencatbox{Categories:}
58 @category{Rational expressions}
59 @category{Package ratpow}
65 @deffn {Function} ratp_lopow (@var{expr}, @var{x})
67 Returns the lowest power of @var{x} in @code{ratnumer(expr)}
71 @c ratp_lopow( x^5 + x^2 , x);
76 (%i2) ratp_lopow( x^5 + x^2 , x);
81 The following example returns 0 since @code{1} equals @code{x^0}:
84 @c ratp_lopow( x^5 + x^2 + 1, x);
89 (%i2) ratp_lopow( x^5 + x^2 + 1, x);
94 The CRE form of the following equation contains @code{sqrt(x)} and
95 @code{x}. Since they are interpreted as independent variables,
96 @code{ratp_lopow} returns @code{0}:
99 @c g:sqrt(x)^5 + sqrt(x)^2;
101 @c ratp_lopow( g, x);
102 @c ratp_lopow( g, sqrt(x));
105 (%i1) load("ratpow")$
107 (%i2) g:sqrt(x)^5 + sqrt(x)^2;
112 (%i3) showratvars(g);
117 (%i4) ratp_lopow( g, x);
121 (%i5) ratp_lopow( g, sqrt(x));
127 @opencatbox{Categories:}
128 @category{Rational expressions}
129 @category{Package ratpow}
135 @deffn {Function} ratp_coeffs (@var{expr}, @var{x})
137 Returns the powers and coefficients of @var{x} in @code{ratnumer(expr)} as a list of length-2 lists;
138 returned coefficients are in CRE form except for numbers.
141 @code{ratnumer(expr)}.
144 @c ratp_coeffs( 4*x^3 + x + sqrt(x), x);
147 (%i1) load("ratpow")$
149 (%i2) ratp_coeffs( 4*x^3 + x + sqrt(x), x);
150 (%o2)/R/ [[3, 4], [1, 1], [0, sqrt(x)]]
153 @opencatbox{Categories:}
154 @category{Rational expressions}
155 @category{Package ratpow}
159 @anchor{ratp_dense_coeffs}
160 @deffn {Function} ratp_dense_coeffs (@var{expr}, @var{x})
162 Returns the coefficients of powers of @var{x} in @code{ratnumer(expr)} from highest to lowest;
163 returned coefficients are in CRE form except for numbers.
167 @c ratp_dense_coeffs( 4*x^3 + x + sqrt(x), x);
170 (%i1) load("ratpow")$
172 (%i2) ratp_dense_coeffs( 4*x^3 + x + sqrt(x), x);
173 (%o2)/R/ [4, 0, 1, sqrt(x)]
177 @opencatbox{Categories:}
178 @category{Rational expressions}
179 @category{Package ratpow}