Você poderia reescrever a expressão em uma expressão maxima e ter
maxima exibi-lo.
(defun maxima-sexp (sexp)
(cond
((typep sexp 'ratio) `((rat simp) ,(numerator sexp) ,(denominator sexp)))
((numberp sexp) sexp)
((symbolp sexp) (intern (concatenate 'string "$" (symbol-name sexp))))
((atom sexp) (error "I don't know how to handle ~S" sexp))
((eq '/ (first sexp))
(list '(MTIMES SIMP)
(maxima-sexp (second sexp))
(list '(MEXPT SIMP) (maxima-sexp (third sexp)) -1)))
((member (first sexp) '(+ - *))
(list* (list (cdr (assoc (first sexp) '((+ . mplus)
(- . mminus)
(* . mtimes)))) 'simp)
(mapcar (function maxima-sexp) (rest sexp))))
(t
(list* (list (intern (concatenate 'string "%" (symbol-name (first sexp)))) 'simp)
(mapcar (function maxima-sexp) (rest sexp))))))
[pjb@kuiper :0.0 ~]$ maxima
Maxima 5.34.1
http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.12 (a.k.a. GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) :lisp (defun maxima-sexp (sexp) (cond ((typep sexp 'ratio) `((rat simp) ,(numerator sexp) ,(denominator sexp))) ((numberp sexp) sexp) ((symbolp sexp) (intern (concatenate 'string "$" (symbol-name sexp)))) ((atom sexp) (error "I don't know how to handle ~S" sexp)) ((eq '/ (first sexp)) (list '(MTIMES SIMP) (maxima-sexp (second sexp)) (list '(MEXPT SIMP) (maxima-sexp (third sexp)) -1))) ((member (first sexp) '(+ - *)) (list* (list (cdr (assoc (first sexp) '((+ . mplus) (- . mminus) (* . mtimes)))) 'simp) (mapcar (function maxima-sexp) (rest sexp)))) (t (list* (list (intern (concatenate 'string "%" (symbol-name (first sexp)))) 'simp) (mapcar (function maxima-sexp) (rest sexp))))))
MAXIMA-SEXP
(%i1) :lisp (displa (maxima-sexp '(+ (- 38 -42) (cos (+ (* (* (* x x) (+ 83 (cos (abs (cos (/ (/ x x) 28)))))) (- (abs x) (+ (abs -16) x))) x)))))
x
cos(x - ((x x) (cos(abs(cos(----))) + 83)) abs(x) (x + abs(- 16))) - 38
x 28
NIL
[pjb@kuiper :0.0 ~]$
http://maxima.sourceforge.net/
--
__Pascal Bourguignon__
http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk