-----Jorge Barros de Abreu wrote: -----
>?Which the package for rationalize function?
>
>Thanks.
The code for 'rationalize' is in /src/maxmin.lisp.
Examples:
(%i1) rationalize(0.5);
(%o1) 1/2
(%i2) rationalize(0.1);
(%o2) 3602879701896397/36028797018963968
(%i3) rationalize(0.1b0);
(%o3) 57646075230342349/576460752303423488
(%i5) rationalize(0.25 * cos(0.1 * x));
(%o5) cos((3602879701896397*x)/36028797018963968)/4
I might be wrong, but I think that 'rationalize' is not a part of 5.9.2.
Also, the 'rationalize' function uses a new function 'cl-rat-to-maxima'
that
is in /src/nparse. If you get these bit pieces of code and place them in
your
'maxima-init.lisp' file, you might be able to get rationalize to work.
Here are these two functions:
;; Richard J. Fateman wrote the big float to rational code and the function
;; cl-rat-to-maxmia.
(defun cl-rat-to-maxima (x) (if (integerp x) x (list '(rat simp) (numerator
x) (denominator x))))
;; Convert all floats and big floats in e to an exact rational
representation.
(defun $rationalize (e)
(cond ((floatp e) (cl-rat-to-maxima (rationalize e)))
(($bfloatp e) (cl-rat-to-maxima (* (cadr e)(expt 2 (- (caddr e) (third
(car e)))))))
(($mapatom e) e)
(t (mfuncall '$fullmap '$rationalize e))))
Barton