diff options
| author | Jay Belanger | 2005-02-15 19:23:46 +0000 |
|---|---|---|
| committer | Jay Belanger | 2005-02-15 19:23:46 +0000 |
| commit | 6a5412e40de1e61fe63ce78d08c5b0515d5765b7 (patch) | |
| tree | 3d2a869b0d311cadd4d5c504ade46115f407c032 | |
| parent | 43817a7520247657839eed5705ab22192c4c94b3 (diff) | |
| download | emacs-6a5412e40de1e61fe63ce78d08c5b0515d5765b7.tar.gz emacs-6a5412e40de1e61fe63ce78d08c5b0515d5765b7.zip | |
Add simplification rules for calcFunc-sec, calcFunc-csc, calcFunc-cot,
calcFunc-sech, calcFunc-csch, calcFunc-coth.
| -rw-r--r-- | lisp/calc/calc-alg.el | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el index 4901883d094..b722261907d 100644 --- a/lisp/calc/calc-alg.el +++ b/lisp/calc/calc-alg.el | |||
| @@ -746,6 +746,55 @@ | |||
| 746 | (list '* (list 'calcFunc-sin (list '* (1- n) a)) | 746 | (list '* (list 'calcFunc-sin (list '* (1- n) a)) |
| 747 | (list 'calcFunc-sin a)))))))) | 747 | (list 'calcFunc-sin a)))))))) |
| 748 | 748 | ||
| 749 | (math-defsimplify calcFunc-sec | ||
| 750 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 751 | (list 'calcFunc-sec (math-neg (nth 1 math-simplify-expr)))) | ||
| 752 | (and (eq calc-angle-mode 'rad) | ||
| 753 | (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi)))) | ||
| 754 | (and n | ||
| 755 | (math-div 1 (math-known-sin (car n) (nth 1 n) 120 300))))) | ||
| 756 | (and (eq calc-angle-mode 'deg) | ||
| 757 | (let ((n (math-integer-plus (nth 1 math-simplify-expr)))) | ||
| 758 | (and n | ||
| 759 | (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300))))) | ||
| 760 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) | ||
| 761 | (math-div | ||
| 762 | 1 | ||
| 763 | (list 'calcFunc-sqrt | ||
| 764 | (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))) | ||
| 765 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) | ||
| 766 | (math-div | ||
| 767 | 1 | ||
| 768 | (nth 1 (nth 1 math-simplify-expr)))) | ||
| 769 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) | ||
| 770 | (list 'calcFunc-sqrt | ||
| 771 | (math-add 1 | ||
| 772 | (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))) | ||
| 773 | |||
| 774 | (math-defsimplify calcFunc-csc | ||
| 775 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 776 | (math-neg (list 'calcFunc-csc (math-neg (nth 1 math-simplify-expr))))) | ||
| 777 | (and (eq calc-angle-mode 'rad) | ||
| 778 | (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi)))) | ||
| 779 | (and n | ||
| 780 | (math-div 1 (math-known-sin (car n) (nth 1 n) 120 0))))) | ||
| 781 | (and (eq calc-angle-mode 'deg) | ||
| 782 | (let ((n (math-integer-plus (nth 1 math-simplify-expr)))) | ||
| 783 | (and n | ||
| 784 | (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 0))))) | ||
| 785 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) | ||
| 786 | (math-div 1 (nth 1 (nth 1 math-simplify-expr)))) | ||
| 787 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) | ||
| 788 | (math-div | ||
| 789 | 1 | ||
| 790 | (list 'calcFunc-sqrt (math-sub 1 (math-sqr | ||
| 791 | (nth 1 (nth 1 math-simplify-expr))))))) | ||
| 792 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) | ||
| 793 | (math-div (list 'calcFunc-sqrt | ||
| 794 | (math-add 1 (math-sqr | ||
| 795 | (nth 1 (nth 1 math-simplify-expr))))) | ||
| 796 | (nth 1 (nth 1 math-simplify-expr)))))) | ||
| 797 | |||
| 749 | (defun math-should-expand-trig (x &optional hyperbolic) | 798 | (defun math-should-expand-trig (x &optional hyperbolic) |
| 750 | (let ((m (math-is-multiple x))) | 799 | (let ((m (math-is-multiple x))) |
| 751 | (and math-living-dangerously | 800 | (and math-living-dangerously |
| @@ -827,6 +876,28 @@ | |||
| 827 | (math-div (list 'calcFunc-sin (nth 1 math-simplify-expr)) | 876 | (math-div (list 'calcFunc-sin (nth 1 math-simplify-expr)) |
| 828 | (list 'calcFunc-cos (nth 1 math-simplify-expr)))))))) | 877 | (list 'calcFunc-cos (nth 1 math-simplify-expr)))))))) |
| 829 | 878 | ||
| 879 | (math-defsimplify calcFunc-cot | ||
| 880 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 881 | (math-neg (list 'calcFunc-cot (math-neg (nth 1 math-simplify-expr))))) | ||
| 882 | (and (eq calc-angle-mode 'rad) | ||
| 883 | (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi)))) | ||
| 884 | (and n | ||
| 885 | (math-div 1 (math-known-tan (car n) (nth 1 n) 120))))) | ||
| 886 | (and (eq calc-angle-mode 'deg) | ||
| 887 | (let ((n (math-integer-plus (nth 1 math-simplify-expr)))) | ||
| 888 | (and n | ||
| 889 | (math-div 1 (math-known-tan (car n) (nth 1 n) '(frac 2 3)))))) | ||
| 890 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin) | ||
| 891 | (math-div (list 'calcFunc-sqrt | ||
| 892 | (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))) | ||
| 893 | (nth 1 (nth 1 math-simplify-expr)))) | ||
| 894 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos) | ||
| 895 | (math-div (nth 1 (nth 1 math-simplify-expr)) | ||
| 896 | (list 'calcFunc-sqrt | ||
| 897 | (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))) | ||
| 898 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan) | ||
| 899 | (math-div 1 (nth 1 (nth 1 math-simplify-expr)))))) | ||
| 900 | |||
| 830 | (defun math-known-tan (plus n mul) | 901 | (defun math-known-tan (plus n mul) |
| 831 | (setq n (math-mul n mul)) | 902 | (setq n (math-mul n mul)) |
| 832 | (and (math-num-integerp n) | 903 | (and (math-num-integerp n) |
| @@ -930,6 +1001,58 @@ | |||
| 930 | (math-div (list 'calcFunc-sinh (nth 1 math-simplify-expr)) | 1001 | (math-div (list 'calcFunc-sinh (nth 1 math-simplify-expr)) |
| 931 | (list 'calcFunc-cosh (nth 1 math-simplify-expr)))))))) | 1002 | (list 'calcFunc-cosh (nth 1 math-simplify-expr)))))))) |
| 932 | 1003 | ||
| 1004 | (math-defsimplify calcFunc-sech | ||
| 1005 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 1006 | (list 'calcFunc-sech (math-neg (nth 1 math-simplify-expr)))) | ||
| 1007 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh) | ||
| 1008 | math-living-dangerously | ||
| 1009 | (math-div | ||
| 1010 | 1 | ||
| 1011 | (list 'calcFunc-sqrt | ||
| 1012 | (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))) | ||
| 1013 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) | ||
| 1014 | math-living-dangerously | ||
| 1015 | (math-div 1 (nth 1 (nth 1 math-simplify-expr))) 1) | ||
| 1016 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) | ||
| 1017 | math-living-dangerously | ||
| 1018 | (list 'calcFunc-sqrt | ||
| 1019 | (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))) | ||
| 1020 | |||
| 1021 | (math-defsimplify calcFunc-csch | ||
| 1022 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 1023 | (math-neg (list 'calcFunc-csch (math-neg (nth 1 math-simplify-expr))))) | ||
| 1024 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh) | ||
| 1025 | math-living-dangerously | ||
| 1026 | (math-div 1 (nth 1 (nth 1 math-simplify-expr)))) | ||
| 1027 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) | ||
| 1028 | math-living-dangerously | ||
| 1029 | (math-div | ||
| 1030 | 1 | ||
| 1031 | (list 'calcFunc-sqrt | ||
| 1032 | (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))) | ||
| 1033 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) | ||
| 1034 | math-living-dangerously | ||
| 1035 | (math-div (list 'calcFunc-sqrt | ||
| 1036 | (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))) | ||
| 1037 | (nth 1 (nth 1 math-simplify-expr)))))) | ||
| 1038 | |||
| 1039 | (math-defsimplify calcFunc-coth | ||
| 1040 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | ||
| 1041 | (math-neg (list 'calcFunc-coth (math-neg (nth 1 math-simplify-expr))))) | ||
| 1042 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh) | ||
| 1043 | math-living-dangerously | ||
| 1044 | (math-div (list 'calcFunc-sqrt | ||
| 1045 | (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)) | ||
| 1046 | (nth 1 (nth 1 math-simplify-expr)))) | ||
| 1047 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh) | ||
| 1048 | math-living-dangerously | ||
| 1049 | (math-div (nth 1 (nth 1 math-simplify-expr)) | ||
| 1050 | (list 'calcFunc-sqrt | ||
| 1051 | (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1)))) | ||
| 1052 | (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh) | ||
| 1053 | math-living-dangerously | ||
| 1054 | (math-div 1 (nth 1 (nth 1 math-simplify-expr)))))) | ||
| 1055 | |||
| 933 | (math-defsimplify calcFunc-arcsin | 1056 | (math-defsimplify calcFunc-arcsin |
| 934 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) | 1057 | (or (and (math-looks-negp (nth 1 math-simplify-expr)) |
| 935 | (math-neg (list 'calcFunc-arcsin (math-neg (nth 1 math-simplify-expr))))) | 1058 | (math-neg (list 'calcFunc-arcsin (math-neg (nth 1 math-simplify-expr))))) |
| @@ -1043,8 +1166,13 @@ | |||
| 1043 | (math-equal-int (nth 2 a) 2) | 1166 | (math-equal-int (nth 2 a) 2) |
| 1044 | (or (and (eq (car-safe (nth 1 a)) 'calcFunc-sinh) | 1167 | (or (and (eq (car-safe (nth 1 a)) 'calcFunc-sinh) |
| 1045 | (list 'calcFunc-cosh (nth 1 (nth 1 a)))) | 1168 | (list 'calcFunc-cosh (nth 1 (nth 1 a)))) |
| 1169 | (and (eq (car-safe (nth 1 a)) 'calcFunc-csch) | ||
| 1170 | (list 'calcFunc-coth (nth 1 (nth 1 a)))) | ||
| 1046 | (and (eq (car-safe (nth 1 a)) 'calcFunc-tan) | 1171 | (and (eq (car-safe (nth 1 a)) 'calcFunc-tan) |
| 1047 | (list '/ 1 (list 'calcFunc-cos | 1172 | (list '/ 1 (list 'calcFunc-cos |
| 1173 | (nth 1 (nth 1 a))))) | ||
| 1174 | (and (eq (car-safe (nth 1 a)) 'calcFunc-cot) | ||
| 1175 | (list '/ 1 (list 'calcFunc-sin | ||
| 1048 | (nth 1 (nth 1 a))))))))) | 1176 | (nth 1 (nth 1 a))))))))) |
| 1049 | (and (eq (car-safe (nth 1 math-simplify-expr)) '^) | 1177 | (and (eq (car-safe (nth 1 math-simplify-expr)) '^) |
| 1050 | (list '^ | 1178 | (list '^ |