In documentation for lreduce and rreduce, supply second argument as an explicit list
[maxima.git] / share / algebra / charsets / fateman-len.lisp
blob3a5f5206f87d14edb64028961cb68f703ecdfdc0
1 ;; from Fateman
4 (in-package :maxima)
6 (defun $charsets_polylength (x)
7 (let ((y (ratf x)))
8 (+ (cp1 (cadr y)) ;numerator
9 (cp1 (cddr y))))) ;denominator
11 (defun cp1(p)
12 ;; sum up the sizes of the terms in the rational form polynomial p
13 (if (pcoefp p) (flatsize p) ; a constant's length in
14 decimal chars
15 (let ((count 0))
16 (do ((i (cdr p)(cddr i)))
17 ((null i) (1+ count)) ; one more for the variable name
18 (incf count (flatsize (car i))) ; length of exponent
19 (incf count (cp1 (cadr i))) ; length of coefficient, recursively
20 ))))
23 ;; Tests:
25 pl(x):=charsets_polylength(x) ;
26 pl( (2*x^3*y^5+3*y*z^2)/5) ; 12
27 pl(x+y) ; 8
28 pl(2*x) ; 4
29 pl(2*x^2*y^3) ; 6
31 ;; This is NOT the same as Maple, but I am guessing that it is
32 ;; a satisfactory ranking of complexity for the
33 ;; characteristic set method. RJF