; diff leitet einen Term nach x ab (ohne Vereinfachungen):
(defun diff (term)
    (cond ((listp term) ; Liste
      (cond ((eq (car term) '+)
               (list '+ (diff (nth 2 term))(diff (nth 3 term))))
            ((eq (car term) '-)
               (list '- (diff (nth 2 term))(diff (nth 3 term))))
            ((eq (car term) '*)
               (list '+ (list '* (diff (nth 2 term)) (nth 3 term))
                        (list '* (nth 2 term) (diff (nth 3 term)))))
            ((eq (car term) '/)
               (list '/ (list '- (list '* (diff (nth 2 term)) (nth 3 term))
                                 (list '* (nth 2 term) (diff (nth 3 term))))
                        (list '* (nth 3 term) (nth 3 term))))
            ;hier Standardfunktionen einfügen
      ))
      ((atom term)
        (cond ((eq term 'x) 1)
              (t 0))) ))
(defun simplify (term &aux a)
    (cond ((atom term) term)
          (t (setq a (list (car term)(simplify (nth 2 term))
                                     (simplify (nth 3 term))))
             (cond ((eq (car a) '+)
                     (cond ((eq (nth 2 a) 0) (nth 3 a))
                           ((eq (nth 3 a) 0) (nth 2 a))(t a)))
                   ((eq (car a) '-)
                     (cond ((eq (nth 3 a) 0) (nth 2 a))(t a)))
                   ((eq (car a) '*)
                     (cond ((or (eq (nth 2 a) 0)(eq (nth 3 a) 0)) 0)
                           ((eq (nth 2 a) 1) (nth 3 a))
                           ((eq (nth 3 a) 1) (nth 2 a))(t a)))
                   ((eq (car a) '/)
                     (cond ((eq (nth 3 a) 1) (nth 2 a))
                           ((eq (nth 2 a) 0) 0)(t a)))))))
(terpri)(terpri)
(princ "Demoprogramm zur Differentiation gebrochen-rationaler Funktionen")
(terpri)(princ "nach der Variablen x - Steffen Goebbels 1990")
(terpri)
(princ "Beispiel : (simplify (diff '(/ x (+ 1 x))))") (terpri)
(princ "Hier wird der Term x/(1+x) abgeleitet und etwas vereinfacht.")(terpri)
(princ "Das Ergebnis : ")(simplify (diff '(/ x (+ 1 x))))

