Commit c431c730 authored by Jay Belanger's avatar Jay Belanger
Browse files

(calcFunc-write-out-power): Rename calcFunc-powerexpand.

(math-write-out-power): Rename math-powerexpand, have it handle
negative exponents.
(calc-writeoutpower): Rename calc-powerexpand.
parent d883348d
...@@ -92,30 +92,39 @@ ...@@ -92,30 +92,39 @@
(and n (list (prefix-numeric-value n))))))) (and n (list (prefix-numeric-value n)))))))
;;; Write out powers (a*b*...)^n as a*b*...*a*b*... ;;; Write out powers (a*b*...)^n as a*b*...*a*b*...
(defun calcFunc-writeoutpower (expr) (defun calcFunc-powerexpand (expr)
(math-normalize (math-map-tree 'math-write-out-power expr))) (math-normalize (math-map-tree 'math-powerexpand expr)))
(defun math-write-out-power (expr) (defun math-powerexpand (expr)
(if (eq (car-safe expr) '^) (if (eq (car-safe expr) '^)
(let ((a (nth 1 expr)) (let ((n (nth 2 expr)))
(n (nth 2 expr)) (cond ((and (integerp n)
(prod (nth 1 expr)) (> n 0))
(i 1)) (let ((i 1)
(if (and (integerp n) (a (nth 1 expr))
(> n 0)) (prod (nth 1 expr)))
(progn (while (< i n)
(while (< i n) (setq prod (math-mul prod a))
(setq prod (math-mul prod a)) (setq i (1+ i)))
(setq i (1+ i))) prod))
prod) ((and (integerp n)
expr)) (< 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)) expr))
(defun calc-writeoutpower () (defun calc-powerexpand ()
(interactive) (interactive)
(calc-slow-wrapper (calc-slow-wrapper
(calc-enter-result 1 "expp" (calc-enter-result 1 "pexp"
(calcFunc-writeoutpower (calc-top-n 1))))) (calcFunc-powerexpand (calc-top-n 1)))))
(defun calc-collect (&optional var) (defun calc-collect (&optional var)
(interactive "sCollect terms involving: ") (interactive "sCollect terms involving: ")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment