aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-09-19 21:11:40 +0000
committerGlenn Morris2009-09-19 21:11:40 +0000
commitf3445fab9fa6609d316b3dbcabb40e02e7a4dfc4 (patch)
treea72ab5971e572bbbaacae9cf500b881049122ded
parenta9c83b2f0cfedf2961217e4fa7ed7fc8d67dfac5 (diff)
downloademacs-f3445fab9fa6609d316b3dbcabb40e02e7a4dfc4.tar.gz
emacs-f3445fab9fa6609d316b3dbcabb40e02e7a4dfc4.zip
(var): Define for compiler.
Delete trailing whitespace.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/calc/calc-alg.el103
-rw-r--r--lisp/calc/calcalg2.el101
3 files changed, 108 insertions, 101 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dfd9aee6bf1..590c26c27ba 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12009-09-19 Glenn Morris <rgm@gnu.org>
2
3 * calc/calc-alg.el (var):
4 * calc/calcalg2.el (var): Define for compiler.
5
12009-09-19 Chong Yidong <cyd@stupidchicken.com> 62009-09-19 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * emacs-lisp/advice.el (ad-get-argument, ad-set-argument): Doc 8 * emacs-lisp/advice.el (ad-get-argument, ad-set-argument): Doc
diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el
index f4be1a5e036..e23ed7c50ca 100644
--- a/lisp/calc/calc-alg.el
+++ b/lisp/calc/calc-alg.el
@@ -53,11 +53,11 @@
53 (calc-slow-wrapper 53 (calc-slow-wrapper
54 (let ((top (calc-top-n 1))) 54 (let ((top (calc-top-n 1)))
55 (if (calc-is-inverse) 55 (if (calc-is-inverse)
56 (setq top 56 (setq top
57 (let ((calc-simplify-mode nil)) 57 (let ((calc-simplify-mode nil))
58 (math-normalize (math-trig-rewrite top))))) 58 (math-normalize (math-trig-rewrite top)))))
59 (if (calc-is-hyperbolic) 59 (if (calc-is-hyperbolic)
60 (setq top 60 (setq top
61 (let ((calc-simplify-mode nil)) 61 (let ((calc-simplify-mode nil))
62 (math-normalize (math-hyperbolic-trig-rewrite top))))) 62 (math-normalize (math-hyperbolic-trig-rewrite top)))))
63 (calc-with-default-simplification 63 (calc-with-default-simplification
@@ -353,7 +353,7 @@
353 (t 353 (t
354 (mapcar 'math-hyperbolic-trig-rewrite fn)))) 354 (mapcar 'math-hyperbolic-trig-rewrite fn))))
355 355
356;; math-top-only is local to math-simplify, but is used by 356;; math-top-only is local to math-simplify, but is used by
357;; math-simplify-step, which is called by math-simplify. 357;; math-simplify-step, which is called by math-simplify.
358(defvar math-top-only) 358(defvar math-top-only)
359 359
@@ -456,7 +456,7 @@
456 aaa temp) 456 aaa temp)
457 (while (memq (car-safe (setq aaa (nth 1 aa))) '(+ -)) 457 (while (memq (car-safe (setq aaa (nth 1 aa))) '(+ -))
458 (if (setq temp (math-combine-sum (nth 2 aaa) (nth 2 math-simplify-expr) 458 (if (setq temp (math-combine-sum (nth 2 aaa) (nth 2 math-simplify-expr)
459 (eq (car aaa) '-) 459 (eq (car aaa) '-)
460 (eq (car math-simplify-expr) '-) t)) 460 (eq (car math-simplify-expr) '-) t))
461 (progn 461 (progn
462 (setcar (cdr (cdr math-simplify-expr)) temp) 462 (setcar (cdr (cdr math-simplify-expr)) temp)
@@ -499,7 +499,7 @@
499 (setcar (cdr math-simplify-expr) (math-mul (nth 1 math-simplify-expr) temp)))) 499 (setcar (cdr math-simplify-expr) (math-mul (nth 1 math-simplify-expr) temp))))
500 (while (and (eq (car-safe (setq aaa (nth 2 aa))) '*) 500 (while (and (eq (car-safe (setq aaa (nth 2 aa))) '*)
501 safe) 501 safe)
502 (if (setq temp (math-combine-prod (nth 1 math-simplify-expr) 502 (if (setq temp (math-combine-prod (nth 1 math-simplify-expr)
503 (nth 1 aaa) nil nil t)) 503 (nth 1 aaa) nil nil t))
504 (progn 504 (progn
505 (setcar (cdr math-simplify-expr) temp) 505 (setcar (cdr math-simplify-expr) temp)
@@ -513,7 +513,7 @@
513 (setcar (cdr (cdr aa)) 1))) 513 (setcar (cdr (cdr aa)) 1)))
514 (if (and (eq (car-safe (nth 1 math-simplify-expr)) 'frac) 514 (if (and (eq (car-safe (nth 1 math-simplify-expr)) 'frac)
515 (memq (nth 1 (nth 1 math-simplify-expr)) '(1 -1))) 515 (memq (nth 1 (nth 1 math-simplify-expr)) '(1 -1)))
516 (math-div (math-mul (nth 2 math-simplify-expr) 516 (math-div (math-mul (nth 2 math-simplify-expr)
517 (nth 1 (nth 1 math-simplify-expr))) 517 (nth 1 (nth 1 math-simplify-expr)))
518 (nth 2 (nth 1 math-simplify-expr))) 518 (nth 2 (nth 1 math-simplify-expr)))
519 math-simplify-expr))) 519 math-simplify-expr)))
@@ -524,18 +524,18 @@
524(defun math-simplify-divide () 524(defun math-simplify-divide ()
525 (let ((np (cdr math-simplify-expr)) 525 (let ((np (cdr math-simplify-expr))
526 (nover nil) 526 (nover nil)
527 (nn (and (or (eq (car math-simplify-expr) '/) 527 (nn (and (or (eq (car math-simplify-expr) '/)
528 (not (Math-realp (nth 2 math-simplify-expr)))) 528 (not (Math-realp (nth 2 math-simplify-expr))))
529 (math-common-constant-factor (nth 2 math-simplify-expr)))) 529 (math-common-constant-factor (nth 2 math-simplify-expr))))
530 n op) 530 n op)
531 (if nn 531 (if nn
532 (progn 532 (progn
533 (setq n (and (or (eq (car math-simplify-expr) '/) 533 (setq n (and (or (eq (car math-simplify-expr) '/)
534 (not (Math-realp (nth 1 math-simplify-expr)))) 534 (not (Math-realp (nth 1 math-simplify-expr))))
535 (math-common-constant-factor (nth 1 math-simplify-expr)))) 535 (math-common-constant-factor (nth 1 math-simplify-expr))))
536 (if (and (eq (car-safe nn) 'frac) (eq (nth 1 nn) 1) (not n)) 536 (if (and (eq (car-safe nn) 'frac) (eq (nth 1 nn) 1) (not n))
537 (progn 537 (progn
538 (setcar (cdr math-simplify-expr) 538 (setcar (cdr math-simplify-expr)
539 (math-mul (nth 2 nn) (nth 1 math-simplify-expr))) 539 (math-mul (nth 2 nn) (nth 1 math-simplify-expr)))
540 (setcar (cdr (cdr math-simplify-expr)) 540 (setcar (cdr (cdr math-simplify-expr))
541 (math-cancel-common-factor (nth 2 math-simplify-expr) nn)) 541 (math-cancel-common-factor (nth 2 math-simplify-expr) nn))
@@ -549,7 +549,7 @@
549 (setcar (cdr (cdr math-simplify-expr)) 549 (setcar (cdr (cdr math-simplify-expr))
550 (math-cancel-common-factor (nth 2 math-simplify-expr) n)) 550 (math-cancel-common-factor (nth 2 math-simplify-expr) n))
551 (if (and (math-negp n) 551 (if (and (math-negp n)
552 (setq op (assq (car math-simplify-expr) 552 (setq op (assq (car math-simplify-expr)
553 calc-tweak-eqn-table))) 553 calc-tweak-eqn-table)))
554 (setcar math-simplify-expr (nth 1 op)))))))) 554 (setcar math-simplify-expr (nth 1 op))))))))
555 (if (and (eq (car-safe (car np)) '/) 555 (if (and (eq (car-safe (car np)) '/)
@@ -576,15 +576,15 @@
576(defvar math-simplify-divisor-nover) 576(defvar math-simplify-divisor-nover)
577(defvar math-simplify-divisor-dover) 577(defvar math-simplify-divisor-dover)
578 578
579(defun math-simplify-divisor (np dp math-simplify-divisor-nover 579(defun math-simplify-divisor (np dp math-simplify-divisor-nover
580 math-simplify-divisor-dover) 580 math-simplify-divisor-dover)
581 (cond ((eq (car-safe (car dp)) '/) 581 (cond ((eq (car-safe (car dp)) '/)
582 (math-simplify-divisor np (cdr (car dp)) 582 (math-simplify-divisor np (cdr (car dp))
583 math-simplify-divisor-nover 583 math-simplify-divisor-nover
584 math-simplify-divisor-dover) 584 math-simplify-divisor-dover)
585 (and (math-known-scalarp (nth 1 (car dp)) t) 585 (and (math-known-scalarp (nth 1 (car dp)) t)
586 (math-simplify-divisor np (cdr (cdr (car dp))) 586 (math-simplify-divisor np (cdr (cdr (car dp)))
587 math-simplify-divisor-nover 587 math-simplify-divisor-nover
588 (not math-simplify-divisor-dover)))) 588 (not math-simplify-divisor-dover))))
589 ((or (or (eq (car math-simplify-expr) '/) 589 ((or (or (eq (car math-simplify-expr) '/)
590 (let ((signs (math-possible-signs (car np)))) 590 (let ((signs (math-possible-signs (car np))))
@@ -594,7 +594,7 @@
594 math-living-dangerously))) 594 math-living-dangerously)))
595 (math-numberp (car np))) 595 (math-numberp (car np)))
596 (let (d 596 (let (d
597 (safe t) 597 (safe t)
598 (scalar (math-known-scalarp (car np)))) 598 (scalar (math-known-scalarp (car np))))
599 (while (and (eq (car-safe (setq d (car dp))) '*) 599 (while (and (eq (car-safe (setq d (car dp))) '*)
600 safe) 600 safe)
@@ -605,10 +605,10 @@
605 (math-simplify-one-divisor np dp)))))) 605 (math-simplify-one-divisor np dp))))))
606 606
607(defun math-simplify-one-divisor (np dp) 607(defun math-simplify-one-divisor (np dp)
608 (let ((temp (math-combine-prod (car np) (car dp) math-simplify-divisor-nover 608 (let ((temp (math-combine-prod (car np) (car dp) math-simplify-divisor-nover
609 math-simplify-divisor-dover t)) 609 math-simplify-divisor-dover t))
610 op) 610 op)
611 (if temp 611 (if temp
612 (progn 612 (progn
613 (and (not (memq (car math-simplify-expr) '(/ calcFunc-eq calcFunc-neq))) 613 (and (not (memq (car math-simplify-expr) '(/ calcFunc-eq calcFunc-neq)))
614 (math-known-negp (car dp)) 614 (math-known-negp (car dp))
@@ -616,7 +616,7 @@
616 (setcar math-simplify-expr (nth 1 op))) 616 (setcar math-simplify-expr (nth 1 op)))
617 (setcar np (if math-simplify-divisor-nover (math-div 1 temp) temp)) 617 (setcar np (if math-simplify-divisor-nover (math-div 1 temp) temp))
618 (setcar dp 1)) 618 (setcar dp 1))
619 (and math-simplify-divisor-dover (not math-simplify-divisor-nover) 619 (and math-simplify-divisor-dover (not math-simplify-divisor-nover)
620 (eq (car math-simplify-expr) '/) 620 (eq (car math-simplify-expr) '/)
621 (eq (car-safe (car dp)) 'calcFunc-sqrt) 621 (eq (car-safe (car dp)) 'calcFunc-sqrt)
622 (Math-integerp (nth 1 (car dp))) 622 (Math-integerp (nth 1 (car dp)))
@@ -717,7 +717,7 @@
717 (math-simplify-add-term (cdr (cdr n)) (cdr (cdr math-simplify-expr)) 717 (math-simplify-add-term (cdr (cdr n)) (cdr (cdr math-simplify-expr))
718 (eq (car n) '-) nil) 718 (eq (car n) '-) nil)
719 (setq np (cdr n))) 719 (setq np (cdr n)))
720 (math-simplify-add-term np (cdr (cdr math-simplify-expr)) nil 720 (math-simplify-add-term np (cdr (cdr math-simplify-expr)) nil
721 (eq np (cdr math-simplify-expr))) 721 (eq np (cdr math-simplify-expr)))
722 (math-simplify-divide) 722 (math-simplify-divide)
723 (let ((signs (math-possible-signs (cons '- (cdr math-simplify-expr))))) 723 (let ((signs (math-possible-signs (cons '- (cdr math-simplify-expr)))))
@@ -784,12 +784,12 @@
784 (and n 784 (and n
785 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 0)))) 785 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 0))))
786 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) 786 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
787 (list 'calcFunc-sqrt (math-sub 1 (math-sqr 787 (list 'calcFunc-sqrt (math-sub 1 (math-sqr
788 (nth 1 (nth 1 math-simplify-expr)))))) 788 (nth 1 (nth 1 math-simplify-expr))))))
789 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) 789 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
790 (math-div (nth 1 (nth 1 math-simplify-expr)) 790 (math-div (nth 1 (nth 1 math-simplify-expr))
791 (list 'calcFunc-sqrt 791 (list 'calcFunc-sqrt
792 (math-add 1 (math-sqr 792 (math-add 1 (math-sqr
793 (nth 1 (nth 1 math-simplify-expr))))))) 793 (nth 1 (nth 1 math-simplify-expr)))))))
794 (let ((m (math-should-expand-trig (nth 1 math-simplify-expr)))) 794 (let ((m (math-should-expand-trig (nth 1 math-simplify-expr))))
795 (and m (integerp (car m)) 795 (and m (integerp (car m))
@@ -814,12 +814,12 @@
814 (and n 814 (and n
815 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300)))) 815 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300))))
816 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) 816 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
817 (list 'calcFunc-sqrt 817 (list 'calcFunc-sqrt
818 (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))) 818 (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))
819 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) 819 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
820 (math-div 1 820 (math-div 1
821 (list 'calcFunc-sqrt 821 (list 'calcFunc-sqrt
822 (math-add 1 822 (math-add 1
823 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))) 823 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))
824 (let ((m (math-should-expand-trig (nth 1 math-simplify-expr)))) 824 (let ((m (math-should-expand-trig (nth 1 math-simplify-expr))))
825 (and m (integerp (car m)) 825 (and m (integerp (car m))
@@ -842,17 +842,17 @@
842 (and n 842 (and n
843 (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300))))) 843 (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300)))))
844 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) 844 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
845 (math-div 845 (math-div
846 1 846 1
847 (list 'calcFunc-sqrt 847 (list 'calcFunc-sqrt
848 (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))) 848 (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))
849 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) 849 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
850 (math-div 850 (math-div
851 1 851 1
852 (nth 1 (nth 1 math-simplify-expr)))) 852 (nth 1 (nth 1 math-simplify-expr))))
853 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) 853 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
854 (list 'calcFunc-sqrt 854 (list 'calcFunc-sqrt
855 (math-add 1 855 (math-add 1
856 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))) 856 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))))
857 857
858(math-defsimplify calcFunc-csc 858(math-defsimplify calcFunc-csc
@@ -869,13 +869,13 @@
869 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) 869 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
870 (math-div 1 (nth 1 (nth 1 math-simplify-expr)))) 870 (math-div 1 (nth 1 (nth 1 math-simplify-expr))))
871 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) 871 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
872 (math-div 872 (math-div
873 1 873 1
874 (list 'calcFunc-sqrt (math-sub 1 (math-sqr 874 (list 'calcFunc-sqrt (math-sub 1 (math-sqr
875 (nth 1 (nth 1 math-simplify-expr))))))) 875 (nth 1 (nth 1 math-simplify-expr)))))))
876 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) 876 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
877 (math-div (list 'calcFunc-sqrt 877 (math-div (list 'calcFunc-sqrt
878 (math-add 1 (math-sqr 878 (math-add 1 (math-sqr
879 (nth 1 (nth 1 math-simplify-expr))))) 879 (nth 1 (nth 1 math-simplify-expr)))))
880 (nth 1 (nth 1 math-simplify-expr)))))) 880 (nth 1 (nth 1 math-simplify-expr))))))
881 881
@@ -1021,7 +1021,7 @@
1021 (math-neg (list 'calcFunc-sinh (math-neg (nth 1 math-simplify-expr))))) 1021 (math-neg (list 'calcFunc-sinh (math-neg (nth 1 math-simplify-expr)))))
1022 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) 1022 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
1023 math-living-dangerously 1023 math-living-dangerously
1024 (list 'calcFunc-sqrt 1024 (list 'calcFunc-sqrt
1025 (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))) 1025 (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))
1026 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) 1026 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
1027 math-living-dangerously 1027 math-living-dangerously
@@ -1045,7 +1045,7 @@
1045 (list 'calcFunc-cosh (math-neg (nth 1 math-simplify-expr)))) 1045 (list 'calcFunc-cosh (math-neg (nth 1 math-simplify-expr))))
1046 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh) 1046 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh)
1047 math-living-dangerously 1047 math-living-dangerously
1048 (list 'calcFunc-sqrt 1048 (list 'calcFunc-sqrt
1049 (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))) 1049 (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))
1050 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) 1050 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
1051 math-living-dangerously 1051 math-living-dangerously
@@ -1090,9 +1090,9 @@
1090 (list 'calcFunc-sech (math-neg (nth 1 math-simplify-expr)))) 1090 (list 'calcFunc-sech (math-neg (nth 1 math-simplify-expr))))
1091 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh) 1091 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh)
1092 math-living-dangerously 1092 math-living-dangerously
1093 (math-div 1093 (math-div
1094 1 1094 1
1095 (list 'calcFunc-sqrt 1095 (list 'calcFunc-sqrt
1096 (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))) 1096 (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))))
1097 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) 1097 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
1098 math-living-dangerously 1098 math-living-dangerously
@@ -1110,9 +1110,9 @@
1110 (math-div 1 (nth 1 (nth 1 math-simplify-expr)))) 1110 (math-div 1 (nth 1 (nth 1 math-simplify-expr))))
1111 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) 1111 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
1112 math-living-dangerously 1112 math-living-dangerously
1113 (math-div 1113 (math-div
1114 1 1114 1
1115 (list 'calcFunc-sqrt 1115 (list 'calcFunc-sqrt
1116 (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))) 1116 (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))))
1117 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) 1117 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
1118 math-living-dangerously 1118 math-living-dangerously
@@ -1205,7 +1205,7 @@
1205 1205
1206(defun math-simplify-sqrt () 1206(defun math-simplify-sqrt ()
1207 (or (and (eq (car-safe (nth 1 math-simplify-expr)) 'frac) 1207 (or (and (eq (car-safe (nth 1 math-simplify-expr)) 'frac)
1208 (math-div (list 'calcFunc-sqrt 1208 (math-div (list 'calcFunc-sqrt
1209 (math-mul (nth 1 (nth 1 math-simplify-expr)) 1209 (math-mul (nth 1 (nth 1 math-simplify-expr))
1210 (nth 2 (nth 1 math-simplify-expr)))) 1210 (nth 2 (nth 1 math-simplify-expr))))
1211 (nth 2 (nth 1 math-simplify-expr)))) 1211 (nth 2 (nth 1 math-simplify-expr))))
@@ -1216,7 +1216,7 @@
1216 (math-mul (math-normalize (list 'calcFunc-sqrt fac)) 1216 (math-mul (math-normalize (list 'calcFunc-sqrt fac))
1217 (math-normalize 1217 (math-normalize
1218 (list 'calcFunc-sqrt 1218 (list 'calcFunc-sqrt
1219 (math-cancel-common-factor 1219 (math-cancel-common-factor
1220 (nth 1 math-simplify-expr) fac)))))) 1220 (nth 1 math-simplify-expr) fac))))))
1221 (and math-living-dangerously 1221 (and math-living-dangerously
1222 (or (and (eq (car-safe (nth 1 math-simplify-expr)) '-) 1222 (or (and (eq (car-safe (nth 1 math-simplify-expr)) '-)
@@ -1230,7 +1230,7 @@
1230 (and (eq (car-safe (nth 1 (nth 2 (nth 1 math-simplify-expr)))) 1230 (and (eq (car-safe (nth 1 (nth 2 (nth 1 math-simplify-expr))))
1231 'calcFunc-cos) 1231 'calcFunc-cos)
1232 (list 'calcFunc-sin 1232 (list 'calcFunc-sin
1233 (nth 1 (nth 1 (nth 2 1233 (nth 1 (nth 1 (nth 2
1234 (nth 1 math-simplify-expr)))))))) 1234 (nth 1 math-simplify-expr))))))))
1235 (and (eq (car-safe (nth 1 math-simplify-expr)) '-) 1235 (and (eq (car-safe (nth 1 math-simplify-expr)) '-)
1236 (math-equal-int (nth 2 (nth 1 math-simplify-expr)) 1) 1236 (math-equal-int (nth 2 (nth 1 math-simplify-expr)) 1)
@@ -1370,7 +1370,7 @@
1370 (or (and (eq (car-safe (nth 1 math-simplify-expr)) '^) 1370 (or (and (eq (car-safe (nth 1 math-simplify-expr)) '^)
1371 (list '^ 1371 (list '^
1372 (nth 1 (nth 1 math-simplify-expr)) 1372 (nth 1 (nth 1 math-simplify-expr))
1373 (math-mul (nth 2 math-simplify-expr) 1373 (math-mul (nth 2 math-simplify-expr)
1374 (nth 2 (nth 1 math-simplify-expr))))) 1374 (nth 2 (nth 1 math-simplify-expr)))))
1375 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-sqrt) 1375 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-sqrt)
1376 (list '^ 1376 (list '^
@@ -1378,9 +1378,9 @@
1378 (math-div (nth 2 math-simplify-expr) 2))) 1378 (math-div (nth 2 math-simplify-expr) 2)))
1379 (and (memq (car-safe (nth 1 math-simplify-expr)) '(* /)) 1379 (and (memq (car-safe (nth 1 math-simplify-expr)) '(* /))
1380 (list (car (nth 1 math-simplify-expr)) 1380 (list (car (nth 1 math-simplify-expr))
1381 (list '^ (nth 1 (nth 1 math-simplify-expr)) 1381 (list '^ (nth 1 (nth 1 math-simplify-expr))
1382 (nth 2 math-simplify-expr)) 1382 (nth 2 math-simplify-expr))
1383 (list '^ (nth 2 (nth 1 math-simplify-expr)) 1383 (list '^ (nth 2 (nth 1 math-simplify-expr))
1384 (nth 2 math-simplify-expr)))))) 1384 (nth 2 math-simplify-expr))))))
1385 (and (math-equal-int (nth 1 math-simplify-expr) 10) 1385 (and (math-equal-int (nth 1 math-simplify-expr) 10)
1386 (eq (car-safe (nth 2 math-simplify-expr)) 'calcFunc-log10) 1386 (eq (car-safe (nth 2 math-simplify-expr)) 'calcFunc-log10)
@@ -1389,7 +1389,7 @@
1389 (math-simplify-exp (nth 2 math-simplify-expr))) 1389 (math-simplify-exp (nth 2 math-simplify-expr)))
1390 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-exp) 1390 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-exp)
1391 (not math-integrating) 1391 (not math-integrating)
1392 (list 'calcFunc-exp (math-mul (nth 1 (nth 1 math-simplify-expr)) 1392 (list 'calcFunc-exp (math-mul (nth 1 (nth 1 math-simplify-expr))
1393 (nth 2 math-simplify-expr)))) 1393 (nth 2 math-simplify-expr))))
1394 (and (equal (nth 1 math-simplify-expr) '(var i var-i)) 1394 (and (equal (nth 1 math-simplify-expr) '(var i var-i))
1395 (math-imaginary-i) 1395 (math-imaginary-i)
@@ -1403,14 +1403,14 @@
1403 (integerp (nth 2 math-simplify-expr)) 1403 (integerp (nth 2 math-simplify-expr))
1404 (>= (nth 2 math-simplify-expr) 2) 1404 (>= (nth 2 math-simplify-expr) 2)
1405 (or (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-cos) 1405 (or (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-cos)
1406 (math-mul (math-pow (nth 1 math-simplify-expr) 1406 (math-mul (math-pow (nth 1 math-simplify-expr)
1407 (- (nth 2 math-simplify-expr) 2)) 1407 (- (nth 2 math-simplify-expr) 2))
1408 (math-sub 1 1408 (math-sub 1
1409 (math-sqr 1409 (math-sqr
1410 (list 'calcFunc-sin 1410 (list 'calcFunc-sin
1411 (nth 1 (nth 1 math-simplify-expr))))))) 1411 (nth 1 (nth 1 math-simplify-expr)))))))
1412 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-cosh) 1412 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-cosh)
1413 (math-mul (math-pow (nth 1 math-simplify-expr) 1413 (math-mul (math-pow (nth 1 math-simplify-expr)
1414 (- (nth 2 math-simplify-expr) 2)) 1414 (- (nth 2 math-simplify-expr) 2))
1415 (math-add 1 1415 (math-add 1
1416 (math-sqr 1416 (math-sqr
@@ -1443,14 +1443,14 @@
1443 (or (and (math-looks-negp (nth 1 math-simplify-expr)) 1443 (or (and (math-looks-negp (nth 1 math-simplify-expr))
1444 (math-neg (list 'calcFunc-erf (math-neg (nth 1 math-simplify-expr))))) 1444 (math-neg (list 'calcFunc-erf (math-neg (nth 1 math-simplify-expr)))))
1445 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-conj) 1445 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-conj)
1446 (list 'calcFunc-conj 1446 (list 'calcFunc-conj
1447 (list 'calcFunc-erf (nth 1 (nth 1 math-simplify-expr))))))) 1447 (list 'calcFunc-erf (nth 1 (nth 1 math-simplify-expr)))))))
1448 1448
1449(math-defsimplify calcFunc-erfc 1449(math-defsimplify calcFunc-erfc
1450 (or (and (math-looks-negp (nth 1 math-simplify-expr)) 1450 (or (and (math-looks-negp (nth 1 math-simplify-expr))
1451 (math-sub 2 (list 'calcFunc-erfc (math-neg (nth 1 math-simplify-expr))))) 1451 (math-sub 2 (list 'calcFunc-erfc (math-neg (nth 1 math-simplify-expr)))))
1452 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-conj) 1452 (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-conj)
1453 (list 'calcFunc-conj 1453 (list 'calcFunc-conj
1454 (list 'calcFunc-erfc (nth 1 (nth 1 math-simplify-expr))))))) 1454 (list 'calcFunc-erfc (nth 1 (nth 1 math-simplify-expr)))))))
1455 1455
1456 1456
@@ -1652,13 +1652,14 @@
1652 (car p)))) 1652 (car p))))
1653 1653
1654;;; If expr is of the form "a + bx + cx^2 + ...", return the list (a b c ...), 1654;;; If expr is of the form "a + bx + cx^2 + ...", return the list (a b c ...),
1655;;; else return nil if not in polynomial form. If "loose" (math-is-poly-loose), 1655;;; else return nil if not in polynomial form. If "loose" (math-is-poly-loose),
1656;;; coefficients may contain x, e.g., sin(x) + cos(x) x^2 is a loose polynomial in x. 1656;;; coefficients may contain x, e.g., sin(x) + cos(x) x^2 is a loose polynomial in x.
1657 1657
1658;; The variables math-is-poly-degree and math-is-poly-loose are local to 1658;; These variables are local to math-is-polynomial, but are used by
1659;; math-is-polynomial, but are used by math-is-poly-rec 1659;; math-is-poly-rec.
1660(defvar math-is-poly-degree) 1660(defvar math-is-poly-degree)
1661(defvar math-is-poly-loose) 1661(defvar math-is-poly-loose)
1662(defvar var)
1662 1663
1663(defun math-is-polynomial (expr var &optional math-is-poly-degree math-is-poly-loose) 1664(defun math-is-polynomial (expr var &optional math-is-poly-degree math-is-poly-loose)
1664 (let* ((math-poly-base-variable (if math-is-poly-loose 1665 (let* ((math-poly-base-variable (if math-is-poly-loose
@@ -1744,7 +1745,7 @@
1744 (let ((p2 (math-is-poly-rec (nth 2 expr) negpow))) 1745 (let ((p2 (math-is-poly-rec (nth 2 expr) negpow)))
1745 (and p2 1746 (and p2
1746 (or (null math-is-poly-degree) 1747 (or (null math-is-poly-degree)
1747 (<= (- (+ (length p1) (length p2)) 2) 1748 (<= (- (+ (length p1) (length p2)) 2)
1748 math-is-poly-degree)) 1749 math-is-poly-degree))
1749 (math-poly-mul p1 p2)))))) 1750 (math-poly-mul p1 p2))))))
1750 ((eq (car expr) '/) 1751 ((eq (car expr) '/)
diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el
index aead48ddc01..f222360ed48 100644
--- a/lisp/calc/calcalg2.el
+++ b/lisp/calc/calcalg2.el
@@ -198,7 +198,7 @@
198 (prefix-numeric-value nterms)))))) 198 (prefix-numeric-value nterms))))))
199 199
200 200
201;; The following are global variables used by math-derivative and some 201;; The following are global variables used by math-derivative and some
202;; related functions 202;; related functions
203(defvar math-deriv-var) 203(defvar math-deriv-var)
204(defvar math-deriv-total) 204(defvar math-deriv-total)
@@ -416,7 +416,7 @@
416 (list 'calcFunc-sec u))))))) 416 (list 'calcFunc-sec u)))))))
417 417
418(put 'calcFunc-sec\' 'math-derivative-1 418(put 'calcFunc-sec\' 'math-derivative-1
419 (function (lambda (u) (math-to-radians-2 419 (function (lambda (u) (math-to-radians-2
420 (math-mul 420 (math-mul
421 (math-normalize 421 (math-normalize
422 (list 'calcFunc-sec u)) 422 (list 'calcFunc-sec u))
@@ -424,7 +424,7 @@
424 (list 'calcFunc-tan u))))))) 424 (list 'calcFunc-tan u)))))))
425 425
426(put 'calcFunc-csc\' 'math-derivative-1 426(put 'calcFunc-csc\' 'math-derivative-1
427 (function (lambda (u) (math-neg 427 (function (lambda (u) (math-neg
428 (math-to-radians-2 428 (math-to-radians-2
429 (math-mul 429 (math-mul
430 (math-normalize 430 (math-normalize
@@ -657,14 +657,14 @@
657;; which are called (directly or indirectly) by math-try-integral. 657;; which are called (directly or indirectly) by math-try-integral.
658(defvar math-integ-depth) 658(defvar math-integ-depth)
659;; math-integ-level is a local variable for math-try-integral, but is used 659;; math-integ-level is a local variable for math-try-integral, but is used
660;; by math-integral, math-do-integral, math-tracing-integral, 660;; by math-integral, math-do-integral, math-tracing-integral,
661;; math-sub-integration, math-integrate-by-parts and 661;; math-sub-integration, math-integrate-by-parts and
662;; math-integrate-by-substitution, which are called (directly or 662;; math-integrate-by-substitution, which are called (directly or
663;; indirectly) by math-try-integral. 663;; indirectly) by math-try-integral.
664(defvar math-integ-level) 664(defvar math-integ-level)
665;; math-integral-limit is a local variable for calcFunc-integ, but is 665;; math-integral-limit is a local variable for calcFunc-integ, but is
666;; used by math-tracing-integral, math-sub-integration and 666;; used by math-tracing-integral, math-sub-integration and
667;; math-try-integration. 667;; math-try-integration.
668(defvar math-integral-limit) 668(defvar math-integral-limit)
669 669
670(defmacro math-tracing-integral (&rest parts) 670(defmacro math-tracing-integral (&rest parts)
@@ -828,11 +828,11 @@
828;; used by math-sub-integration. 828;; used by math-sub-integration.
829(defvar math-old-integ) 829(defvar math-old-integ)
830 830
831;; The variables math-t1, math-t2 and math-t3 are local to 831;; The variables math-t1, math-t2 and math-t3 are local to
832;; math-do-integral, math-try-solve-for and math-decompose-poly, but 832;; math-do-integral, math-try-solve-for and math-decompose-poly, but
833;; are used by functions they call (directly or indirectly); 833;; are used by functions they call (directly or indirectly);
834;; math-do-integral calls math-do-integral-methods; 834;; math-do-integral calls math-do-integral-methods;
835;; math-try-solve-for calls math-try-solve-prod, 835;; math-try-solve-for calls math-try-solve-prod,
836;; math-solve-find-root-term and math-solve-find-root-in-prod; 836;; math-solve-find-root-term and math-solve-find-root-in-prod;
837;; math-decompose-poly calls math-solve-poly-funny-powers and 837;; math-decompose-poly calls math-solve-poly-funny-powers and
838;; math-solve-crunch-poly. 838;; math-solve-crunch-poly.
@@ -1075,12 +1075,12 @@
1075 (list 'calcFunc-integfailed expr))) 1075 (list 'calcFunc-integfailed expr)))
1076 1076
1077;; math-so-far is a local variable for math-do-integral-methods, but 1077;; math-so-far is a local variable for math-do-integral-methods, but
1078;; is used by math-integ-try-linear-substitutions and 1078;; is used by math-integ-try-linear-substitutions and
1079;; math-integ-try-substitutions. 1079;; math-integ-try-substitutions.
1080(defvar math-so-far) 1080(defvar math-so-far)
1081 1081
1082;; math-integ-expr is a local variable for math-do-integral-methods, 1082;; math-integ-expr is a local variable for math-do-integral-methods,
1083;; but is used by math-integ-try-linear-substitutions and 1083;; but is used by math-integ-try-linear-substitutions and
1084;; math-integ-try-substitutions. 1084;; math-integ-try-substitutions.
1085(defvar math-integ-expr) 1085(defvar math-integ-expr)
1086 1086
@@ -1253,8 +1253,8 @@
1253 temp (let (calc-next-why) 1253 temp (let (calc-next-why)
1254 (math-simplify-extended 1254 (math-simplify-extended
1255 (math-solve-for (math-sub v temp) 0 v nil))) 1255 (math-solve-for (math-sub v temp) 0 v nil)))
1256 temp (if (and (eq (car-safe temp) '/) 1256 temp (if (and (eq (car-safe temp) '/)
1257 (math-zerop (nth 2 temp))) 1257 (math-zerop (nth 2 temp)))
1258 nil temp))))) 1258 nil temp)))))
1259 (setcar (cdr math-cur-record) 'busy))))) 1259 (setcar (cdr math-cur-record) 'busy)))))
1260 1260
@@ -1675,7 +1675,7 @@
1675(math-defintegral calcFunc-sec 1675(math-defintegral calcFunc-sec
1676 (and (equal u math-integ-var) 1676 (and (equal u math-integ-var)
1677 (math-from-radians-2 1677 (math-from-radians-2
1678 (list 'calcFunc-ln 1678 (list 'calcFunc-ln
1679 (math-add 1679 (math-add
1680 (list 'calcFunc-sec u) 1680 (list 'calcFunc-sec u)
1681 (list 'calcFunc-tan u)))))) 1681 (list 'calcFunc-tan u))))))
@@ -1683,7 +1683,7 @@
1683(math-defintegral calcFunc-csc 1683(math-defintegral calcFunc-csc
1684 (and (equal u math-integ-var) 1684 (and (equal u math-integ-var)
1685 (math-from-radians-2 1685 (math-from-radians-2
1686 (list 'calcFunc-ln 1686 (list 'calcFunc-ln
1687 (math-sub 1687 (math-sub
1688 (list 'calcFunc-csc u) 1688 (list 'calcFunc-csc u)
1689 (list 'calcFunc-cot u)))))) 1689 (list 'calcFunc-cot u))))))
@@ -1882,13 +1882,14 @@
1882(defvar math-tabulate-initial nil) 1882(defvar math-tabulate-initial nil)
1883(defvar math-tabulate-function nil) 1883(defvar math-tabulate-function nil)
1884 1884
1885;; The variables calc-low and calc-high are local to calcFunc-table, 1885;; These variables are local to calcFunc-table, but are used by
1886;; but are used by math-scan-for-limits. 1886;; math-scan-for-limits.
1887(defvar calc-low) 1887(defvar calc-low)
1888(defvar calc-high) 1888(defvar calc-high)
1889(defvar var)
1889 1890
1890(defun calcFunc-table (expr var &optional calc-low calc-high step) 1891(defun calcFunc-table (expr var &optional calc-low calc-high step)
1891 (or calc-low 1892 (or calc-low
1892 (setq calc-low '(neg (var inf var-inf)) calc-high '(var inf var-inf))) 1893 (setq calc-low '(neg (var inf var-inf)) calc-high '(var inf var-inf)))
1893 (or calc-high (setq calc-high calc-low calc-low 1)) 1894 (or calc-high (setq calc-high calc-low calc-low 1))
1894 (and (or (math-infinitep calc-low) (math-infinitep calc-high)) 1895 (and (or (math-infinitep calc-low) (math-infinitep calc-high))
@@ -2348,23 +2349,23 @@
2348 2349
2349(defvar math-solve-ranges nil) 2350(defvar math-solve-ranges nil)
2350(defvar math-solve-sign) 2351(defvar math-solve-sign)
2351;;; Attempt to reduce math-solve-lhs = math-solve-rhs to 2352;;; Attempt to reduce math-solve-lhs = math-solve-rhs to
2352;;; math-solve-var = math-solve-rhs', where math-solve-var appears 2353;;; math-solve-var = math-solve-rhs', where math-solve-var appears
2353;;; in math-solve-lhs but not in math-solve-rhs or math-solve-rhs'; 2354;;; in math-solve-lhs but not in math-solve-rhs or math-solve-rhs';
2354;;; return math-solve-rhs'. 2355;;; return math-solve-rhs'.
2355;;; Uses global values: math-solve-var, math-solve-full. 2356;;; Uses global values: math-solve-var, math-solve-full.
2356(defvar math-solve-var) 2357(defvar math-solve-var)
2357(defvar math-solve-full) 2358(defvar math-solve-full)
2358 2359
2359;; The variables math-solve-lhs, math-solve-rhs and math-try-solve-sign 2360;; The variables math-solve-lhs, math-solve-rhs and math-try-solve-sign
2360;; are local to math-try-solve-for, but are used by math-try-solve-prod. 2361;; are local to math-try-solve-for, but are used by math-try-solve-prod.
2361;; (math-solve-lhs and math-solve-rhs are is also local to 2362;; (math-solve-lhs and math-solve-rhs are is also local to
2362;; math-decompose-poly, but used by math-solve-poly-funny-powers.) 2363;; math-decompose-poly, but used by math-solve-poly-funny-powers.)
2363(defvar math-solve-lhs) 2364(defvar math-solve-lhs)
2364(defvar math-solve-rhs) 2365(defvar math-solve-rhs)
2365(defvar math-try-solve-sign) 2366(defvar math-try-solve-sign)
2366 2367
2367(defun math-try-solve-for 2368(defun math-try-solve-for
2368 (math-solve-lhs math-solve-rhs &optional math-try-solve-sign no-poly) 2369 (math-solve-lhs math-solve-rhs &optional math-try-solve-sign no-poly)
2369 (let (math-t1 math-t2 math-t3) 2370 (let (math-t1 math-t2 math-t3)
2370 (cond ((equal math-solve-lhs math-solve-var) 2371 (cond ((equal math-solve-lhs math-solve-var)
@@ -2395,7 +2396,7 @@
2395 (setq math-t2 (funcall math-t1 '(var SOLVEDUM SOLVEDUM))) 2396 (setq math-t2 (funcall math-t1 '(var SOLVEDUM SOLVEDUM)))
2396 (eq (math-expr-contains-count math-t2 '(var SOLVEDUM SOLVEDUM)) 1) 2397 (eq (math-expr-contains-count math-t2 '(var SOLVEDUM SOLVEDUM)) 1)
2397 (setq math-t3 (math-solve-above-dummy math-t2)) 2398 (setq math-t3 (math-solve-above-dummy math-t2))
2398 (setq math-t1 (math-try-solve-for 2399 (setq math-t1 (math-try-solve-for
2399 (math-sub (nth 1 (nth 1 math-solve-lhs)) 2400 (math-sub (nth 1 (nth 1 math-solve-lhs))
2400 (math-expr-subst 2401 (math-expr-subst
2401 math-t2 math-t3 2402 math-t2 math-t3
@@ -2407,8 +2408,8 @@
2407 (and math-try-solve-sign (- math-try-solve-sign)))) 2408 (and math-try-solve-sign (- math-try-solve-sign))))
2408 ((and (not (eq math-solve-full 't)) (math-try-solve-prod))) 2409 ((and (not (eq math-solve-full 't)) (math-try-solve-prod)))
2409 ((and (not no-poly) 2410 ((and (not no-poly)
2410 (setq math-t2 2411 (setq math-t2
2411 (math-decompose-poly math-solve-lhs 2412 (math-decompose-poly math-solve-lhs
2412 math-solve-var 15 math-solve-rhs))) 2413 math-solve-var 15 math-solve-rhs)))
2413 (setq math-t1 (cdr (nth 1 math-t2)) 2414 (setq math-t1 (cdr (nth 1 math-t2))
2414 math-t1 (let ((math-solve-ranges math-solve-ranges)) 2415 math-t1 (let ((math-solve-ranges math-solve-ranges))
@@ -2419,7 +2420,7 @@
2419 ((= (length math-t1) 3) 2420 ((= (length math-t1) 3)
2420 (apply 'math-solve-quadratic (car math-t2) math-t1)) 2421 (apply 'math-solve-quadratic (car math-t2) math-t1))
2421 ((= (length math-t1) 2) 2422 ((= (length math-t1) 2)
2422 (apply 'math-solve-linear 2423 (apply 'math-solve-linear
2423 (car math-t2) math-try-solve-sign math-t1)) 2424 (car math-t2) math-try-solve-sign math-t1))
2424 (math-solve-full 2425 (math-solve-full
2425 (math-poly-all-roots (car math-t2) math-t1)) 2426 (math-poly-all-roots (car math-t2) math-t1))
@@ -2474,7 +2475,7 @@
2474 ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var)) 2475 ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var))
2475 (math-try-solve-for (nth 2 math-solve-lhs) 2476 (math-try-solve-for (nth 2 math-solve-lhs)
2476 (math-sub (nth 1 math-solve-lhs) math-solve-rhs) 2477 (math-sub (nth 1 math-solve-lhs) math-solve-rhs)
2477 (and math-try-solve-sign 2478 (and math-try-solve-sign
2478 (- math-try-solve-sign)))) 2479 (- math-try-solve-sign))))
2479 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var)) 2480 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var))
2480 (math-try-solve-for (nth 1 math-solve-lhs) 2481 (math-try-solve-for (nth 1 math-solve-lhs)
@@ -2488,7 +2489,7 @@
2488 (nth 2 math-solve-lhs))))) 2489 (nth 2 math-solve-lhs)))))
2489 ((eq (car math-solve-lhs) 'calcFunc-log) 2490 ((eq (car math-solve-lhs) 'calcFunc-log)
2490 (cond ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var)) 2491 (cond ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var))
2491 (math-try-solve-for (nth 1 math-solve-lhs) 2492 (math-try-solve-for (nth 1 math-solve-lhs)
2492 (math-pow (nth 2 math-solve-lhs) math-solve-rhs))) 2493 (math-pow (nth 2 math-solve-lhs) math-solve-rhs)))
2493 ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var)) 2494 ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var))
2494 (math-try-solve-for (nth 2 math-solve-lhs) (math-pow 2495 (math-try-solve-for (nth 2 math-solve-lhs) (math-pow
@@ -2503,7 +2504,7 @@
2503 (and math-try-solve-sign math-t1 2504 (and math-try-solve-sign math-t1
2504 (if (integerp math-t1) 2505 (if (integerp math-t1)
2505 (* math-t1 math-try-solve-sign) 2506 (* math-t1 math-try-solve-sign)
2506 (funcall math-t1 math-solve-lhs 2507 (funcall math-t1 math-solve-lhs
2507 math-try-solve-sign))))) 2508 math-try-solve-sign)))))
2508 ((and (symbolp (car math-solve-lhs)) 2509 ((and (symbolp (car math-solve-lhs))
2509 (setq math-t1 (get (car math-solve-lhs) 'math-inverse-n)) 2510 (setq math-t1 (get (car math-solve-lhs) 'math-inverse-n))
@@ -2521,12 +2522,12 @@
2521 (cond ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var)) 2522 (cond ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var))
2522 (math-try-solve-for (nth 2 math-solve-lhs) 2523 (math-try-solve-for (nth 2 math-solve-lhs)
2523 (math-div math-solve-rhs (nth 1 math-solve-lhs)) 2524 (math-div math-solve-rhs (nth 1 math-solve-lhs))
2524 (math-solve-sign math-try-solve-sign 2525 (math-solve-sign math-try-solve-sign
2525 (nth 1 math-solve-lhs)))) 2526 (nth 1 math-solve-lhs))))
2526 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var)) 2527 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var))
2527 (math-try-solve-for (nth 1 math-solve-lhs) 2528 (math-try-solve-for (nth 1 math-solve-lhs)
2528 (math-div math-solve-rhs (nth 2 math-solve-lhs)) 2529 (math-div math-solve-rhs (nth 2 math-solve-lhs))
2529 (math-solve-sign math-try-solve-sign 2530 (math-solve-sign math-try-solve-sign
2530 (nth 2 math-solve-lhs)))) 2531 (nth 2 math-solve-lhs))))
2531 ((Math-zerop math-solve-rhs) 2532 ((Math-zerop math-solve-rhs)
2532 (math-solve-prod (let ((math-solve-ranges math-solve-ranges)) 2533 (math-solve-prod (let ((math-solve-ranges math-solve-ranges))
@@ -2536,12 +2537,12 @@
2536 (cond ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var)) 2537 (cond ((not (math-expr-contains (nth 1 math-solve-lhs) math-solve-var))
2537 (math-try-solve-for (nth 2 math-solve-lhs) 2538 (math-try-solve-for (nth 2 math-solve-lhs)
2538 (math-div (nth 1 math-solve-lhs) math-solve-rhs) 2539 (math-div (nth 1 math-solve-lhs) math-solve-rhs)
2539 (math-solve-sign math-try-solve-sign 2540 (math-solve-sign math-try-solve-sign
2540 (nth 1 math-solve-lhs)))) 2541 (nth 1 math-solve-lhs))))
2541 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var)) 2542 ((not (math-expr-contains (nth 2 math-solve-lhs) math-solve-var))
2542 (math-try-solve-for (nth 1 math-solve-lhs) 2543 (math-try-solve-for (nth 1 math-solve-lhs)
2543 (math-mul math-solve-rhs (nth 2 math-solve-lhs)) 2544 (math-mul math-solve-rhs (nth 2 math-solve-lhs))
2544 (math-solve-sign math-try-solve-sign 2545 (math-solve-sign math-try-solve-sign
2545 (nth 2 math-solve-lhs)))) 2546 (nth 2 math-solve-lhs))))
2546 ((setq math-t1 (math-try-solve-for (math-sub (nth 1 math-solve-lhs) 2547 ((setq math-t1 (math-try-solve-for (math-sub (nth 1 math-solve-lhs)
2547 (math-mul (nth 2 math-solve-lhs) 2548 (math-mul (nth 2 math-solve-lhs)
@@ -2581,14 +2582,14 @@
2581 (math-normalize math-t2))) 2582 (math-normalize math-t2)))
2582 ((math-looks-negp (nth 2 math-solve-lhs)) 2583 ((math-looks-negp (nth 2 math-solve-lhs))
2583 (math-try-solve-for 2584 (math-try-solve-for
2584 (list '^ (nth 1 math-solve-lhs) 2585 (list '^ (nth 1 math-solve-lhs)
2585 (math-neg (nth 2 math-solve-lhs))) 2586 (math-neg (nth 2 math-solve-lhs)))
2586 (math-div 1 math-solve-rhs))) 2587 (math-div 1 math-solve-rhs)))
2587 ((and (eq math-solve-full t) 2588 ((and (eq math-solve-full t)
2588 (Math-integerp (nth 2 math-solve-lhs)) 2589 (Math-integerp (nth 2 math-solve-lhs))
2589 (math-known-realp (nth 1 math-solve-lhs))) 2590 (math-known-realp (nth 1 math-solve-lhs)))
2590 (setq math-t1 (math-normalize 2591 (setq math-t1 (math-normalize
2591 (list 'calcFunc-nroot math-solve-rhs 2592 (list 'calcFunc-nroot math-solve-rhs
2592 (nth 2 math-solve-lhs)))) 2593 (nth 2 math-solve-lhs))))
2593 (if (math-evenp (nth 2 math-solve-lhs)) 2594 (if (math-evenp (nth 2 math-solve-lhs))
2594 (setq math-t1 (math-solve-get-sign math-t1))) 2595 (setq math-t1 (math-solve-get-sign math-t1)))
@@ -2596,7 +2597,7 @@
2596 (nth 1 math-solve-lhs) math-t1 2597 (nth 1 math-solve-lhs) math-t1
2597 (and math-try-solve-sign 2598 (and math-try-solve-sign
2598 (math-oddp (nth 2 math-solve-lhs)) 2599 (math-oddp (nth 2 math-solve-lhs))
2599 (math-solve-sign math-try-solve-sign 2600 (math-solve-sign math-try-solve-sign
2600 (nth 2 math-solve-lhs))))) 2601 (nth 2 math-solve-lhs)))))
2601 (t (math-try-solve-for 2602 (t (math-try-solve-for
2602 (nth 1 math-solve-lhs) 2603 (nth 1 math-solve-lhs)
@@ -2628,7 +2629,7 @@
2628 (nth 2 math-solve-lhs)))) 2629 (nth 2 math-solve-lhs))))
2629 (and math-try-solve-sign 2630 (and math-try-solve-sign
2630 (math-oddp (nth 2 math-solve-lhs)) 2631 (math-oddp (nth 2 math-solve-lhs))
2631 (math-solve-sign math-try-solve-sign 2632 (math-solve-sign math-try-solve-sign
2632 (nth 2 math-solve-lhs))))))))) 2633 (nth 2 math-solve-lhs)))))))))
2633 (t nil))) 2634 (t nil)))
2634 2635
@@ -2665,7 +2666,7 @@
2665 (setq math-t2 (math-mul (or math-poly-mult-powers 1) 2666 (setq math-t2 (math-mul (or math-poly-mult-powers 1)
2666 (let ((calc-prefer-frac t)) 2667 (let ((calc-prefer-frac t))
2667 (math-div 1 math-poly-frac-powers))) 2668 (math-div 1 math-poly-frac-powers)))
2668 math-t1 (math-is-polynomial 2669 math-t1 (math-is-polynomial
2669 (math-simplify (calcFunc-expand math-t1)) math-solve-b 50)))) 2670 (math-simplify (calcFunc-expand math-t1)) math-solve-b 50))))
2670 2671
2671;;; This converts "a x^8 + b x^5 + c x^2" to "(a (x^3)^2 + b (x^3) + c) * x^2". 2672;;; This converts "a x^8 + b x^5 + c x^2" to "(a (x^3)^2 + b (x^3) + c) * x^2".
@@ -2694,7 +2695,7 @@
2694 (setq math-t3 (cons scale (cdr math-t3)) 2695 (setq math-t3 (cons scale (cdr math-t3))
2695 math-t1 new-t1)))) 2696 math-t1 new-t1))))
2696 (setq scale (1- scale))) 2697 (setq scale (1- scale)))
2697 (setq math-t3 (list (math-mul (car math-t3) math-t2) 2698 (setq math-t3 (list (math-mul (car math-t3) math-t2)
2698 (math-mul count math-t2))) 2699 (math-mul count math-t2)))
2699 (<= (1- (length math-t1)) max-degree))))) 2700 (<= (1- (length math-t1)) max-degree)))))
2700 2701
@@ -2733,7 +2734,7 @@
2733 (and (not (equal math-solve-b math-solve-lhs)) 2734 (and (not (equal math-solve-b math-solve-lhs))
2734 (or (not (memq (car-safe math-solve-b) '(+ -))) sub-rhs) 2735 (or (not (memq (car-safe math-solve-b) '(+ -))) sub-rhs)
2735 (setq math-t3 '(1 0) math-t2 1 2736 (setq math-t3 '(1 0) math-t2 1
2736 math-t1 (math-is-polynomial math-solve-lhs 2737 math-t1 (math-is-polynomial math-solve-lhs
2737 math-solve-b 50)) 2738 math-solve-b 50))
2738 (if (and (equal math-poly-neg-powers '(1)) 2739 (if (and (equal math-poly-neg-powers '(1))
2739 (memq math-poly-mult-powers '(nil 1)) 2740 (memq math-poly-mult-powers '(nil 1))
@@ -3217,7 +3218,7 @@
3217 (and (not (math-expr-contains (nth 2 x) math-solve-var)) 3218 (and (not (math-expr-contains (nth 2 x) math-solve-var))
3218 (math-solve-find-root-in-prod (nth 1 x)))))))) 3219 (math-solve-find-root-in-prod (nth 1 x))))))))
3219 3220
3220;; The variable math-solve-vars is local to math-solve-system, 3221;; The variable math-solve-vars is local to math-solve-system,
3221;; but is used by math-solve-system-rec. 3222;; but is used by math-solve-system-rec.
3222(defvar math-solve-vars) 3223(defvar math-solve-vars)
3223 3224
@@ -3282,7 +3283,7 @@
3282 (while (and e2 3283 (while (and e2
3283 (setq res2 (or (and (eq (car e2) eprev) 3284 (setq res2 (or (and (eq (car e2) eprev)
3284 res2) 3285 res2)
3285 (math-solve-for (car e2) 0 3286 (math-solve-for (car e2) 0
3286 math-solve-system-vv 3287 math-solve-system-vv
3287 math-solve-full)))) 3288 math-solve-full))))
3288 (setq eprev (car e2) 3289 (setq eprev (car e2)
@@ -3313,8 +3314,8 @@
3313 solns))) 3314 solns)))
3314 (if elim 3315 (if elim
3315 s 3316 s
3316 (cons (cons 3317 (cons (cons
3317 math-solve-system-vv 3318 math-solve-system-vv
3318 (apply 'append math-solve-system-res)) 3319 (apply 'append math-solve-system-res))
3319 s))))) 3320 s)))))
3320 (not math-solve-system-res)))) 3321 (not math-solve-system-res))))
@@ -3350,9 +3351,9 @@
3350 (lambda (r) 3351 (lambda (r)
3351 (if math-solve-simplifying 3352 (if math-solve-simplifying
3352 (math-simplify 3353 (math-simplify
3353 (math-expr-subst 3354 (math-expr-subst
3354 (car x) math-solve-system-vv r)) 3355 (car x) math-solve-system-vv r))
3355 (math-expr-subst 3356 (math-expr-subst
3356 (car x) math-solve-system-vv r)))) 3357 (car x) math-solve-system-vv r))))
3357 (car res2))) 3358 (car res2)))
3358 x (cdr x) 3359 x (cdr x)