## [Maxima-commits] CVS: maxima/src simp.lisp,1.102,1.103

 [Maxima-commits] CVS: maxima/src simp.lisp,1.102,1.103 From: Dieter Kaiser - 2010-02-19 22:31:05 ```Update of /cvsroot/maxima/maxima/src In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2883/src Modified Files: simp.lisp Log Message: Optimizing the order of checks in the code for simplifying the abs function. The code is much faster, if abs functions with complicated expressions are involved. Index: simp.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/src/simp.lisp,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- simp.lisp 15 Feb 2010 23:00:29 -0000 1.102 +++ simp.lisp 19 Feb 2010 22:30:50 -0000 1.103 @@ -2174,12 +2174,12 @@ ((and (not (atom (car x))) (eq (caar (car x)) 'mabs) - (not (member (\$csign (cadr (car x))) - '(\$complex imaginary))) (equal (cadr x) 1) - (alike1 (cadr (car x)) (cadr (cadr fm))) (integerp (caddr (cadr fm))) - (< (caddr (cadr fm)) -1)) + (< (caddr (cadr fm)) -1) + (alike1 (cadr (car x)) (cadr (cadr fm))) + (not (member (\$csign (cadr (car x))) + '(\$complex imaginary)))) ;; 1/x^n*abs(x) -> 1/(x^(n-2)*abs(x)), where n an integer ;; Replace 1/x^n -> 1/x^(n-2) (setq temp (power (cadr (cadr fm)) @@ -2195,12 +2195,12 @@ ((and (not (atom (car x))) (eq (caar (car x)) 'mabs) - (not (member (\$csign (cadr (car x))) - '(\$complex imaginary))) (equal (cadr x) -1) - (alike1 (cadr (car x)) (cadr (cadr fm))) (integerp (caddr (cadr fm))) - (> (caddr (cadr fm)) 1)) + (> (caddr (cadr fm)) 1) + (alike1 (cadr (car x)) (cadr (cadr fm))) + (not (member (\$csign (cadr (car x))) + '(\$complex imaginary)))) ;; x^n/abs(x) -> x^(n-2)*abs(x), where n an integer. ;; Replace x^n -> x^(n-2) (setq temp (power (cadr (cadr fm)) @@ -2217,12 +2217,12 @@ ((and (not (atom (cadr fm))) (not (atom (cadr (cadr fm)))) (eq (caaadr (cadr fm)) 'mabs) - (not (member (\$csign (cadadr (cadr fm))) - '(\$complex imaginary))) (equal (caddr (cadr fm)) -1) - (alike1 (cadadr (cadr fm)) (car x)) (integerp (cadr x)) - (> (cadr x) 1)) + (> (cadr x) 1) + (alike1 (cadadr (cadr fm)) (car x)) + (not (member (\$csign (cadadr (cadr fm))) + '(\$complex imaginary)))) ;; 1/abs(x)*x^n -> x^(n-2)*abs(x), where n an integer. ;; Replace 1/abs(x) -> abs(x) (setq temp (cadr (cadr fm))) @@ -2250,11 +2250,11 @@ ((and (not (atom (cadr fm))) (eq (caar (cadr fm)) 'mabs) - (not (member (\$csign (cadr (cadr fm))) - '(\$complex imaginary))) - (alike1 (cadr (cadr fm)) (car x)) (integerp (cadr x)) - (< (cadr x) -1)) + (< (cadr x) -1) + (alike1 (cadr (cadr fm)) (car x)) + (not (member (\$csign (cadr (cadr fm))) + '(\$complex imaginary)))) ;; abs(x)/x^n -> 1/(x^(n-2)*abs(x)), where n an integer. ;; Replace abs(x) -> 1/abs(x). (setq temp (power (cadr fm) -1)) ```

 [Maxima-commits] CVS: maxima/src simp.lisp,1.102,1.103 From: Dieter Kaiser - 2010-02-19 22:31:05 ```Update of /cvsroot/maxima/maxima/src In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2883/src Modified Files: simp.lisp Log Message: Optimizing the order of checks in the code for simplifying the abs function. The code is much faster, if abs functions with complicated expressions are involved. Index: simp.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/src/simp.lisp,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- simp.lisp 15 Feb 2010 23:00:29 -0000 1.102 +++ simp.lisp 19 Feb 2010 22:30:50 -0000 1.103 @@ -2174,12 +2174,12 @@ ((and (not (atom (car x))) (eq (caar (car x)) 'mabs) - (not (member (\$csign (cadr (car x))) - '(\$complex imaginary))) (equal (cadr x) 1) - (alike1 (cadr (car x)) (cadr (cadr fm))) (integerp (caddr (cadr fm))) - (< (caddr (cadr fm)) -1)) + (< (caddr (cadr fm)) -1) + (alike1 (cadr (car x)) (cadr (cadr fm))) + (not (member (\$csign (cadr (car x))) + '(\$complex imaginary)))) ;; 1/x^n*abs(x) -> 1/(x^(n-2)*abs(x)), where n an integer ;; Replace 1/x^n -> 1/x^(n-2) (setq temp (power (cadr (cadr fm)) @@ -2195,12 +2195,12 @@ ((and (not (atom (car x))) (eq (caar (car x)) 'mabs) - (not (member (\$csign (cadr (car x))) - '(\$complex imaginary))) (equal (cadr x) -1) - (alike1 (cadr (car x)) (cadr (cadr fm))) (integerp (caddr (cadr fm))) - (> (caddr (cadr fm)) 1)) + (> (caddr (cadr fm)) 1) + (alike1 (cadr (car x)) (cadr (cadr fm))) + (not (member (\$csign (cadr (car x))) + '(\$complex imaginary)))) ;; x^n/abs(x) -> x^(n-2)*abs(x), where n an integer. ;; Replace x^n -> x^(n-2) (setq temp (power (cadr (cadr fm)) @@ -2217,12 +2217,12 @@ ((and (not (atom (cadr fm))) (not (atom (cadr (cadr fm)))) (eq (caaadr (cadr fm)) 'mabs) - (not (member (\$csign (cadadr (cadr fm))) - '(\$complex imaginary))) (equal (caddr (cadr fm)) -1) - (alike1 (cadadr (cadr fm)) (car x)) (integerp (cadr x)) - (> (cadr x) 1)) + (> (cadr x) 1) + (alike1 (cadadr (cadr fm)) (car x)) + (not (member (\$csign (cadadr (cadr fm))) + '(\$complex imaginary)))) ;; 1/abs(x)*x^n -> x^(n-2)*abs(x), where n an integer. ;; Replace 1/abs(x) -> abs(x) (setq temp (cadr (cadr fm))) @@ -2250,11 +2250,11 @@ ((and (not (atom (cadr fm))) (eq (caar (cadr fm)) 'mabs) - (not (member (\$csign (cadr (cadr fm))) - '(\$complex imaginary))) - (alike1 (cadr (cadr fm)) (car x)) (integerp (cadr x)) - (< (cadr x) -1)) + (< (cadr x) -1) + (alike1 (cadr (cadr fm)) (car x)) + (not (member (\$csign (cadr (cadr fm))) + '(\$complex imaginary)))) ;; abs(x)/x^n -> 1/(x^(n-2)*abs(x)), where n an integer. ;; Replace abs(x) -> 1/abs(x). (setq temp (power (cadr fm) -1)) ```