From: SourceForge.net <noreply@so...>  20080326 01:29:14

Bugs item #580721, was opened at 20020712 14:38 Message generated for change (Comment added) made by dgildea You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=580721&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core  Trigonometry Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Raymond Toy (rtoy) Assigned to: Nobody/Anonymous (nobody) Summary: trigexpand bug Initial Comment: Consider this: (C1) display2d:false; (D1) FALSE (C2) tan(%pi/2+x); (D2) COT(x) (C3) tan(%pi/2+%pi*x); (D3) TAN(%PI*x+%PI/2) (C4) %,trigexpand; Division by 0  an error. Quitting. To debug this try DEBUGMODE(TRUE);) d3 should have been expanded into cot(%pi*x) instead of getting a division by zero error.  >Comment By: Dan Gildea (dgildea) Date: 20080325 21:29 Message: Logged In: YES user_id=1797506 Originator: NO The proposed patch disables the following simplification: (%i1) declare(n, integer); (%o1) done (%i2) tan(n*2*%pi); (%o2) 0 However, it almost fixes bugs 903190, 1553866 and 1755550.  Comment By: Rupert Swarbrick (rswarbrick) Date: 20071228 12:15 Message: Logged In: YES user_id=1673565 Originator: NO I think I've posted a patch onto the mailing list that fixes this. I can't work out how to attach files here, so the link is: http://thread.gmane.org/gmane.comp.mathematics.maxima.general/19076  Comment By: Rupert Swarbrick (rswarbrick) Date: 20071226 21:38 Message: Logged In: YES user_id=1673565 Originator: NO So the first thing that's wrong is that %piargstan/cot shouldn't return nonnil for stuff like tan(pi/2) as they aren't defined, let alone simplifiable. Here's an amended and reformatted version with variables renamed and a possible bug due to reuse of variable names eliminated too (I think) (defun %piargstan/cot (x) (displa x) (let ((coeff (linearize (coefficient x '$%pi 1))) (zlrem (coefficient x '$%pi 0)) (sinofcoeffpi) (cosofcoeffpi)) (cond ((and (zerop1 zlrem) (setq sinofcoeffpi (%piargs coeff nil)) (not (zerop1 (setq cosofcoeffpi (%piargs (cons (car coeff) (rplus 1//2 (cdr coeff))) nil))))) ;; sinofcoeffpi and cosofcoeffpi are only nonnil if they ;; are constants that %piargsoffset could compute, and we just ;; checked that cosofcoeffpi was nonzero. Thus we can just ;; return their quotient. (div sinofcoeffpi cosofcoeffpi)) ((not (mevenp (car coeff))) nil) ((integerp (setq x (mmod (cdr coeff) 2))) (consexp '%tan zlrem)) ((or (alike1 1//2 x) (alike1 '((rat) 3 2) x)) (neg (consexp '%cot zlrem))))))  Comment By: Rupert Swarbrick (rswarbrick) Date: 20071226 21:29 Message: Logged In: YES user_id=1673565 Originator: NO Ah. Of course tan(pi/2) = infinity ...  Comment By: Rupert Swarbrick (rswarbrick) Date: 20071225 20:10 Message: Logged In: YES user_id=1673565 Originator: NO Hi, a bit more information: the error's caused by a (div 1 0) which gets returned in %piargstan/cot, called by simp%tan. You can reproduce more simply by just calling tan(%pi/2), trigexpand; I'm trying to work out what the functions are _supposed_ to do. Maybe then I'll be able to fix it!  Comment By: Robert Dodier (robert_dodier) Date: 20060326 18:40 Message: Logged In: YES user_id=501686 For the record, same problem observed in maxima 5.9.3.  You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=580721&group_id=4933 