From 7526e2bf4e33c25f1d7952fb5d037a4e78d29ad8 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Wed, 6 Mar 2002 18:01:58 +0000 Subject: [PATCH] updated the description of degree()/ldegree() --- doc/tutorial/ginac.texi | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 717d5b10..2af37ad4 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -3443,9 +3443,34 @@ int ex::degree(const ex & s); int ex::ldegree(const ex & s); @end example -which also work reliably on non-expanded input polynomials (they even work -on rational functions, returning the asymptotic degree). To extract -a coefficient with a certain power from an expanded polynomial you use +These functions only work reliably if the input polynomial is collected in +terms of the object @samp{s}. Otherwise, they are only guaranteed to return +the upper/lower bounds of the exponents. If you need accurate results, you +have to call @code{expand()} and/or @code{collect()} on the input polynomial. +For example + +@example +> a=(x+1)^2-x^2; +(1+x)^2-x^2; +> degree(a,x); +2 +> degree(expand(a),x); +1 +@end example + +@code{degree()} also works on rational functions, returning the asymptotic +degree: + +@example +> degree((x+1)/(x^3+1),x); +-2 +@end example + +If the input is not a polynomial or rational function in the variable @samp{s}, +the behavior of @code{degree()} and @code{ldegree()} is undefined. + +To extract a coefficient with a certain power from an expanded +polynomial you use @example ex ex::coeff(const ex & s, int n); -- 2.24.1