Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: SourceForge.net <noreply@so...> - 2007-12-27 02:38:45
|
Bugs item #580721, was opened at 2002-07-12 19:38 Message generated for change (Comment added) made by rswarbrick 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: Rupert Swarbrick (rswarbrick) Date: 2007-12-27 02:38 Message: Logged In: YES user_id=1673565 Originator: NO So the first thing that's wrong is that %piargs-tan/cot shouldn't return non-nil 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 %piargs-tan/cot (x) (displa x) (let ((coeff (linearize (coefficient x '$%pi 1))) (zl-rem (coefficient x '$%pi 0)) (sin-of-coeff-pi) (cos-of-coeff-pi)) (cond ((and (zerop1 zl-rem) (setq sin-of-coeff-pi (%piargs coeff nil)) (not (zerop1 (setq cos-of-coeff-pi (%piargs (cons (car coeff) (rplus 1//2 (cdr coeff))) nil))))) ;; sin-of-coeff-pi and cos-of-coeff-pi are only non-nil if they ;; are constants that %piargs-offset could compute, and we just ;; checked that cos-of-coeff-pi was nonzero. Thus we can just ;; return their quotient. (div sin-of-coeff-pi cos-of-coeff-pi)) ((not (mevenp (car coeff))) nil) ((integerp (setq x (mmod (cdr coeff) 2))) (cons-exp '%tan zl-rem)) ((or (alike1 1//2 x) (alike1 '((rat) 3 2) x)) (neg (cons-exp '%cot zl-rem)))))) ---------------------------------------------------------------------- Comment By: Rupert Swarbrick (rswarbrick) Date: 2007-12-27 02:29 Message: Logged In: YES user_id=1673565 Originator: NO Ah. Of course tan(pi/2) = infinity ... ---------------------------------------------------------------------- Comment By: Rupert Swarbrick (rswarbrick) Date: 2007-12-26 01: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 %piargs-tan/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: 2006-03-27 00: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 |