From: Jay Belanger <jay.p.belanger@gmail.com>
Date: Tue, 15 Feb 2005 19:27:17 +0000 (+0000)
Subject: Add simplification rules for calcFunc-sec, calcFunc-csc, calcFunc-cot.
X-Git-Tag: ttn-vms-21-2-B4~2270
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=40b444acab7a616650166acccdba7b0c75f0e701;p=emacs.git

Add simplification rules for calcFunc-sec, calcFunc-csc, calcFunc-cot.
---

diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el
index e8a3abfe958..4b3c284ddad 100644
--- a/lisp/calc/calc-units.el
+++ b/lisp/calc/calc-units.el
@@ -1241,6 +1241,45 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).")
 	      (eq (nth 1 (nth 2 rad)) 'rad)
 	      (list 'calcFunc-tan (nth 1 rad))))))
 
+(math-defsimplify calcFunc-sec
+  (and math-simplifying-units
+       (math-units-in-expr-p (nth 1 math-simplify-expr) nil)
+       (let ((rad (math-simplify-units
+		   (math-evaluate-expr
+		    (math-to-standard-units (nth 1 math-simplify-expr) nil))))
+	     (calc-angle-mode 'rad))
+	 (and (eq (car-safe rad) '*)
+	      (math-realp (nth 1 rad))
+	      (eq (car-safe (nth 2 rad)) 'var)
+	      (eq (nth 1 (nth 2 rad)) 'rad)
+	      (list 'calcFunc-sec (nth 1 rad))))))
+
+(math-defsimplify calcFunc-csc
+  (and math-simplifying-units
+       (math-units-in-expr-p (nth 1 math-simplify-expr) nil)
+       (let ((rad (math-simplify-units
+		   (math-evaluate-expr
+		    (math-to-standard-units (nth 1 math-simplify-expr) nil))))
+	     (calc-angle-mode 'rad))
+	 (and (eq (car-safe rad) '*)
+	      (math-realp (nth 1 rad))
+	      (eq (car-safe (nth 2 rad)) 'var)
+	      (eq (nth 1 (nth 2 rad)) 'rad)
+	      (list 'calcFunc-csc (nth 1 rad))))))
+
+(math-defsimplify calcFunc-cot
+  (and math-simplifying-units
+       (math-units-in-expr-p (nth 1 math-simplify-expr) nil)
+       (let ((rad (math-simplify-units
+		   (math-evaluate-expr
+		    (math-to-standard-units (nth 1 math-simplify-expr) nil))))
+	     (calc-angle-mode 'rad))
+	 (and (eq (car-safe rad) '*)
+	      (math-realp (nth 1 rad))
+	      (eq (car-safe (nth 2 rad)) 'var)
+	      (eq (nth 1 (nth 2 rad)) 'rad)
+	      (list 'calcFunc-cot (nth 1 rad))))))
+
 
 (defun math-remove-units (expr)
   (if (math-check-unit-name expr)