aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJay Belanger <[email protected]>2005-02-15 19:23:46 +0000
committerJay Belanger <[email protected]>2005-02-15 19:23:46 +0000
commit6a5412e40de1e61fe63ce78d08c5b0515d5765b7 (patch)
tree3d2a869b0d311cadd4d5c504ade46115f407c032 /lisp
parent43817a7520247657839eed5705ab22192c4c94b3 (diff)
Add simplification rules for calcFunc-sec, calcFunc-csc, calcFunc-cot,
calcFunc-sech, calcFunc-csch, calcFunc-coth.
Diffstat (limited to 'lisp')
-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 4901883d09..b722261907 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 '^