# HG changeset patch # User Jay Belanger # Date 1126121231 0 # Node ID 22640ddbd499d8d9e445fd603836cb2c08aac7e3 # Parent d96b22b8de337ce6c8f026bc2550ea4979e40f0b (math-expand-term): Multiply out the powers when in matrix mode. diff -r d96b22b8de33 -r 22640ddbd499 lisp/calc/calc-poly.el --- a/lisp/calc/calc-poly.el Wed Sep 07 18:48:34 2005 +0000 +++ b/lisp/calc/calc-poly.el Wed Sep 07 19:27:11 2005 +0000 @@ -1069,18 +1069,45 @@ (math-add-or-sub (list '/ (nth 1 (nth 1 expr)) (nth 2 expr)) (list '/ (nth 2 (nth 1 expr)) (nth 2 expr)) nil (eq (car (nth 1 expr)) '-))) + ((and (eq calc-matrix-mode 'matrix) + (eq (car-safe expr) '^) + (natnump (nth 2 expr)) + (> (nth 2 expr) 1) + (memq (car-safe (nth 1 expr)) '(+ -))) + (if (= (nth 2 expr) 2) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr)) + (list '* (nth 2 (nth 1 expr)) (nth 1 expr)) + nil (eq (car (nth 1 expr)) '-)) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + (list '* (nth 2 (nth 1 expr)) (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + nil (eq (car (nth 1 expr)) '-)))) ((and (eq (car-safe expr) '^) (memq (car-safe (nth 1 expr)) '(+ -)) (integerp (nth 2 expr)) - (if (> (nth 2 expr) 0) - (or (and (or (> math-mt-many 500000) (< math-mt-many -500000)) - (math-expand-power (nth 1 expr) (nth 2 expr) - nil t)) - (list '* - (nth 1 expr) - (list '^ (nth 1 expr) (1- (nth 2 expr))))) - (if (< (nth 2 expr) 0) - (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr)))))))) + (if (and (eq calc-matrix-mode 'matrix) + (> (nth 2 expr) 1)) + (if (= (nth 2 expr) 2) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr)) + (list '* (nth 2 (nth 1 expr)) (nth 1 expr)) + nil (eq (car (nth 1 expr)) '-)) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) + (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + (list '* (nth 2 (nth 1 expr)) + (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + nil (eq (car (nth 1 expr)) '-))) + (if (> (nth 2 expr) 0) + (or (and (or (> math-mt-many 500000) (< math-mt-many -500000)) + (math-expand-power (nth 1 expr) (nth 2 expr) + nil t)) + (list '* + (nth 1 expr) + (list '^ (nth 1 expr) (1- (nth 2 expr))))) + (if (< (nth 2 expr) 0) + (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr))))))))) (t expr))) (defun calcFunc-expand (expr &optional many)