summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-alg.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2005-02-18 00:41:50 +0000
committerMiles Bader <miles@gnu.org>2005-02-18 00:41:50 +0000
commit8d46efcc0f2045a1e5a2739c55ba6a88fbf4bcfc (patch)
treebc968a02587d51199537bb335d5494e756e35fdf /lisp/calc/calc-alg.el
parent8589dc17f80450f5773a2d449fa6d94c9bb04fe3 (diff)
parent9b516537a9899900647d4eae5ec8778e6837ad3c (diff)
downloademacs-8d46efcc0f2045a1e5a2739c55ba6a88fbf4bcfc.tar.gz
emacs-8d46efcc0f2045a1e5a2739c55ba6a88fbf4bcfc.tar.bz2
emacs-8d46efcc0f2045a1e5a2739c55ba6a88fbf4bcfc.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-96 Move Gnus images into etc/images * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-97 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-105 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-14 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-15 Update from CVS: lisp/imap.el (imap-log): Doc fix. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-16 Merge from emacs--cvs-trunk--0
Diffstat (limited to 'lisp/calc/calc-alg.el')
-rw-r--r--lisp/calc/calc-alg.el128
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 @@
(list '* (list 'calcFunc-sin (list '* (1- n) a))
(list 'calcFunc-sin a))))))))
+(math-defsimplify calcFunc-sec
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (list 'calcFunc-sec (math-neg (nth 1 math-simplify-expr))))
+ (and (eq calc-angle-mode 'rad)
+ (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi))))
+ (and n
+ (math-div 1 (math-known-sin (car n) (nth 1 n) 120 300)))))
+ (and (eq calc-angle-mode 'deg)
+ (let ((n (math-integer-plus (nth 1 math-simplify-expr))))
+ (and n
+ (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 300)))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
+ (math-div
+ 1
+ (list 'calcFunc-sqrt
+ (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
+ (math-div
+ 1
+ (nth 1 (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
+ (list 'calcFunc-sqrt
+ (math-add 1
+ (math-sqr (nth 1 (nth 1 math-simplify-expr))))))))
+
+(math-defsimplify calcFunc-csc
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (math-neg (list 'calcFunc-csc (math-neg (nth 1 math-simplify-expr)))))
+ (and (eq calc-angle-mode 'rad)
+ (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi))))
+ (and n
+ (math-div 1 (math-known-sin (car n) (nth 1 n) 120 0)))))
+ (and (eq calc-angle-mode 'deg)
+ (let ((n (math-integer-plus (nth 1 math-simplify-expr))))
+ (and n
+ (math-div 1 (math-known-sin (car n) (nth 1 n) '(frac 2 3) 0)))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
+ (math-div 1 (nth 1 (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
+ (math-div
+ 1
+ (list 'calcFunc-sqrt (math-sub 1 (math-sqr
+ (nth 1 (nth 1 math-simplify-expr)))))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
+ (math-div (list 'calcFunc-sqrt
+ (math-add 1 (math-sqr
+ (nth 1 (nth 1 math-simplify-expr)))))
+ (nth 1 (nth 1 math-simplify-expr))))))
+
(defun math-should-expand-trig (x &optional hyperbolic)
(let ((m (math-is-multiple x)))
(and math-living-dangerously
@@ -827,6 +876,28 @@
(math-div (list 'calcFunc-sin (nth 1 math-simplify-expr))
(list 'calcFunc-cos (nth 1 math-simplify-expr))))))))
+(math-defsimplify calcFunc-cot
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (math-neg (list 'calcFunc-cot (math-neg (nth 1 math-simplify-expr)))))
+ (and (eq calc-angle-mode 'rad)
+ (let ((n (math-linear-in (nth 1 math-simplify-expr) '(var pi var-pi))))
+ (and n
+ (math-div 1 (math-known-tan (car n) (nth 1 n) 120)))))
+ (and (eq calc-angle-mode 'deg)
+ (let ((n (math-integer-plus (nth 1 math-simplify-expr))))
+ (and n
+ (math-div 1 (math-known-tan (car n) (nth 1 n) '(frac 2 3))))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsin)
+ (math-div (list 'calcFunc-sqrt
+ (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))
+ (nth 1 (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccos)
+ (math-div (nth 1 (nth 1 math-simplify-expr))
+ (list 'calcFunc-sqrt
+ (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctan)
+ (math-div 1 (nth 1 (nth 1 math-simplify-expr))))))
+
(defun math-known-tan (plus n mul)
(setq n (math-mul n mul))
(and (math-num-integerp n)
@@ -930,6 +1001,58 @@
(math-div (list 'calcFunc-sinh (nth 1 math-simplify-expr))
(list 'calcFunc-cosh (nth 1 math-simplify-expr))))))))
+(math-defsimplify calcFunc-sech
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (list 'calcFunc-sech (math-neg (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh)
+ math-living-dangerously
+ (math-div
+ 1
+ (list 'calcFunc-sqrt
+ (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
+ math-living-dangerously
+ (math-div 1 (nth 1 (nth 1 math-simplify-expr))) 1)
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
+ math-living-dangerously
+ (list 'calcFunc-sqrt
+ (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr))))))))
+
+(math-defsimplify calcFunc-csch
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (math-neg (list 'calcFunc-csch (math-neg (nth 1 math-simplify-expr)))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh)
+ math-living-dangerously
+ (math-div 1 (nth 1 (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
+ math-living-dangerously
+ (math-div
+ 1
+ (list 'calcFunc-sqrt
+ (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
+ math-living-dangerously
+ (math-div (list 'calcFunc-sqrt
+ (math-sub 1 (math-sqr (nth 1 (nth 1 math-simplify-expr)))))
+ (nth 1 (nth 1 math-simplify-expr))))))
+
+(math-defsimplify calcFunc-coth
+ (or (and (math-looks-negp (nth 1 math-simplify-expr))
+ (math-neg (list 'calcFunc-coth (math-neg (nth 1 math-simplify-expr)))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arcsinh)
+ math-living-dangerously
+ (math-div (list 'calcFunc-sqrt
+ (math-add (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))
+ (nth 1 (nth 1 math-simplify-expr))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arccosh)
+ math-living-dangerously
+ (math-div (nth 1 (nth 1 math-simplify-expr))
+ (list 'calcFunc-sqrt
+ (math-sub (math-sqr (nth 1 (nth 1 math-simplify-expr))) 1))))
+ (and (eq (car-safe (nth 1 math-simplify-expr)) 'calcFunc-arctanh)
+ math-living-dangerously
+ (math-div 1 (nth 1 (nth 1 math-simplify-expr))))))
+
(math-defsimplify calcFunc-arcsin
(or (and (math-looks-negp (nth 1 math-simplify-expr))
(math-neg (list 'calcFunc-arcsin (math-neg (nth 1 math-simplify-expr)))))
@@ -1043,8 +1166,13 @@
(math-equal-int (nth 2 a) 2)
(or (and (eq (car-safe (nth 1 a)) 'calcFunc-sinh)
(list 'calcFunc-cosh (nth 1 (nth 1 a))))
+ (and (eq (car-safe (nth 1 a)) 'calcFunc-csch)
+ (list 'calcFunc-coth (nth 1 (nth 1 a))))
(and (eq (car-safe (nth 1 a)) 'calcFunc-tan)
(list '/ 1 (list 'calcFunc-cos
+ (nth 1 (nth 1 a)))))
+ (and (eq (car-safe (nth 1 a)) 'calcFunc-cot)
+ (list '/ 1 (list 'calcFunc-sin
(nth 1 (nth 1 a)))))))))
(and (eq (car-safe (nth 1 math-simplify-expr)) '^)
(list '^