mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-30 08:09:04 +00:00
(calcFunc-write-out-power): Rename calcFunc-powerexpand.
(math-write-out-power): Rename math-powerexpand, have it handle negative exponents. (calc-writeoutpower): Rename calc-powerexpand.
This commit is contained in:
parent
d883348df8
commit
c431c73028
@ -92,30 +92,39 @@
|
||||
(and n (list (prefix-numeric-value n)))))))
|
||||
|
||||
;;; Write out powers (a*b*...)^n as a*b*...*a*b*...
|
||||
(defun calcFunc-writeoutpower (expr)
|
||||
(math-normalize (math-map-tree 'math-write-out-power expr)))
|
||||
(defun calcFunc-powerexpand (expr)
|
||||
(math-normalize (math-map-tree 'math-powerexpand expr)))
|
||||
|
||||
(defun math-write-out-power (expr)
|
||||
(defun math-powerexpand (expr)
|
||||
(if (eq (car-safe expr) '^)
|
||||
(let ((a (nth 1 expr))
|
||||
(n (nth 2 expr))
|
||||
(prod (nth 1 expr))
|
||||
(i 1))
|
||||
(if (and (integerp n)
|
||||
(let ((n (nth 2 expr)))
|
||||
(cond ((and (integerp n)
|
||||
(> n 0))
|
||||
(progn
|
||||
(let ((i 1)
|
||||
(a (nth 1 expr))
|
||||
(prod (nth 1 expr)))
|
||||
(while (< i n)
|
||||
(setq prod (math-mul prod a))
|
||||
(setq i (1+ i)))
|
||||
prod)
|
||||
expr))
|
||||
prod))
|
||||
((and (integerp n)
|
||||
(< n 0))
|
||||
(let ((i -1)
|
||||
(a (math-pow (nth 1 expr) -1))
|
||||
(prod (math-pow (nth 1 expr) -1)))
|
||||
(while (> i n)
|
||||
(setq prod (math-mul a prod))
|
||||
(setq i (1- i)))
|
||||
prod))
|
||||
(t
|
||||
expr)))
|
||||
expr))
|
||||
|
||||
(defun calc-writeoutpower ()
|
||||
(defun calc-powerexpand ()
|
||||
(interactive)
|
||||
(calc-slow-wrapper
|
||||
(calc-enter-result 1 "expp"
|
||||
(calcFunc-writeoutpower (calc-top-n 1)))))
|
||||
(calc-enter-result 1 "pexp"
|
||||
(calcFunc-powerexpand (calc-top-n 1)))))
|
||||
|
||||
(defun calc-collect (&optional var)
|
||||
(interactive "sCollect terms involving: ")
|
||||
|
Loading…
Reference in New Issue
Block a user