The integrate property on mexpt needs work:
(1) The code following ;; integrate(a^b,b); is unreachable. Presumably the integral property on mexpt is
only called on the function x --> x^n (and never on x --> a^x).
(2) The freeof check is silly---the code assumes that an expression is real valued if it is free of %i.
Instead of asksign, an askequal would be more appropriate. But there is no askequal function.
Of course Maxima could return a split rule function instead of using asksign (or askequal). There are (good)
arguments for and against that.
For askequal, here is a hastily written function
(defun $askequal (a b)
(let ((answer (meqp a b)))
(setq answer
(cond ((eq answer t) '$yes)
((eq answer nil) '$no)
(t
(retrieve `((mtext) "Is " ,a "equal to " ,b "?") nil))))
(cond ((eq answer '$no)
(assume (take '($notequal) a b))
answer)
((eq answer '$yes)
(assume (take '($equal) a b))
answer)
(t
(mtell "Please answer either yes or no.")
($askequal a b)))))
;; integrate(x^n,x) = if n # -1 then x^(n+1)/(n+1) else logmabs(x)
(defun integrate-mexpt (x n)
(cond ((eq t (mnqp n -1))
(setq n (add n 1))
(div (power x n) n))
((eq t (meqp n -1))
(logmabs x)) ; that's log(abs(x)) when logabs is true, and log(x) otherwise.
(t
($askequal n -1)
(integrate-mexpt x n)))) ; is this too risky (infinite loop?)
(putprop 'mexpt `((x n) ,(lambda (x n) (integrate-mexpt x n))) 'integral)
--Barton
;; Integral of a^b == ((mexpt) a b)
(putprop 'mexpt
`((a b)
;;integrate(a^b,a);
,(lambda (a b)
(cond
((or (equal b -1)
(and (not (mnump b))
(freeof '$%i b)
(eq (asksign (power (add b 1) 2)) '$zero)))
(logmabs a))
(t
'((mtimes) ((mexpt) a ((mplus) b 1)) ((mexpt) ((mplus) b 1) -1)))))
;; integrate(a^b,b);
((mtimes) ((mexpt) a b) ((mexpt) ((%log) a) -1)))
'integral)
________________________________________