Proposed bug fix for Bug 505443



The above bug says that when halfangles is true we get:

(C1) halfangles:true;

(D1) 				     TRUE
(C2) sin(x/2);

			       SQRT(1 - COS(x))
(D2) 			       ----------------
				   SQRT(2)


This is clearly wrong when X is negative.

One possible solution is for maxima to return

			  SQRT(1 - COS(x)) SIGNUM(x)
(D3) 			  --------------------------
				   SQRT(2)

which is correct.

I've attached a proposed patch that implements this for half angles
for sin and cos.  Still need to work on the solution for sinh.  I
think the other half-angle formulas for tan, cot, tanh, coth are
right.

Also, with this change, if we have assume(x > 0), then expand(d3) will
very nicely replace signum(x) with 1.

Opinions?

Ray


--- logarc.lisp	8 May 2000 06:09:41 -0000	1.1.1.1
+++ logarc.lisp	26 Jun 2002 21:54:10 -0000
@@ -51,7 +51,8 @@
 (defun halfangleaux (f a)  ;; f=function; a=twice argument
    (let ((sw (memq f '(%cos %cot %coth %cosh))))
      (cond ((memq f '(%sin %cos))
-	    (power (div (add 1 (porm sw (take '(%cos) a))) 2) (1//2)))
+	    (mul `((%signum) ,(morp sw a))
+		 (power (div (add 1 (porm sw (take '(%cos) a))) 2) (1//2))))
 	   ((memq f '(%tan %cot))
 	    (div (add 1 (porm sw (take '(%cos) a))) (take '(%sin) a)))
 	   ((memq f '(%sinh %cosh))