From: SourceForge.net <no...@so...> - 2006-12-10 20:17:54
|
Bugs item #1607567, was opened at 2006-12-02 16:49 Message generated for change (Comment added) made by macrakis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1607567&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: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: trigreduce([atan(sin(a)/cos(a))]) => [ atan(tan(a)) ] (FIX) Initial Comment: trigexpand( [ atan(sin(a)/cos(a)) ] ) => atan(tan(a)) (UNSIMPLIFIED!) whereas trigexpand( atan(sin(a)/cos(a)) ) => a and atan(tan(a)) => a Though the simplification atan(tan(a))=> is questionable (it needs to do reduction), it is weird that putting the argument to trigexpand in a list changes the behavior. ---------------------------------------------------------------------- >Comment By: Stavros Macrakis (macrakis) Date: 2006-12-10 15:17 Message: Logged In: YES user_id=588346 Originator: YES Actually, my suggested fix only works in some cases. Better would be the following: BEFORE: ((mbagp e) (cons (car e) (mapcar #'sp1 (cdr e)))) AFTER: ((mbagp e) (cons (list (caar e)) (mapcar #'(lambda (u) (gcdred (sp1 u))) (cdr e)))))) Note two things here: any "simp" flags on the bag are dropped (so this will work if bags come to include sets some day) and gcdred is applied as in the top level of $trigreduce. Sorry I didn't get it right the first time. ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2006-12-08 21:13 Message: Logged In: YES user_id=28849 Originator: NO This change works for me. I get a and [a] for results. I'll apply the fix soon. ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2006-12-08 14:31 Message: Logged In: YES user_id=588346 Originator: YES The problem is that sp1 isn't handling simplification quite right. The result is ((MLIST SIMP) ((%ATAN) ((%TAN SIMP) $A))) The %ATAN doesn't have a SIMP flag, though it is within a SIMP expression. The fix is simple. In trgred.lisp, function sp1: BEFORE: ((mbagp e) (cons (car e) (mapcar #'sp1 (cdr e)))) AFTER: ((mbagp e) (cons (car e) (mapcar #'(lambda (q) (simplifya (sp1 q))) (cdr e)))) Interestingly, trigreduce doesn't go inside unknown functions at all, e.g. trigreduce( f(sin(x)/cos(x)) ) doesn't do anything at all. I wonder if there is a good reason for this? ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2006-12-08 13:15 Message: Logged In: YES user_id=28849 Originator: NO With current CVS, the example with sin(x)^2 gives the same results whether it's a list or not. Also, if you :lisp (trace $trigreduce), you can see that trigreduce([atan(sin(a)/cos(a))]) returns [atan(tan(a))] and trigreduce(atan(sin(a)/cos(a)) returns atan(tan(a)). Something after trigreduce returns causes the simplification to happen. Perhaps in meval or something? ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2006-12-04 12:40 Message: Logged In: YES user_id=588346 Originator: YES Other simplifications also don't happen: trigreduce( sin(x)^2 ) => (1- cos(2*x))/2 (OK) trigreduce([sin(x)^2]) => [ (2-2*cos(2*x))/4 ] (?) ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2006-12-04 12:30 Message: Logged In: YES user_id=588346 Originator: YES Sorry, it's trigreduce in Maxima 5.10.0 GCL 2.6.8 Windows2k Athlon trigreduce(atan(sin(a)/cos(a))) => a trigreduce([atan(sin(a)/cos(a))]) => [atan(tan(a))] PS I should always cut and paste rather than retyping.... ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2006-12-04 11:49 Message: Logged In: YES user_id=28849 Originator: NO What version? With 5.10.0 and cmucl, trigexpand([atan(sin(a)/cos(a))]) => [atan(sin(a)/cos(a))] Corresponding result if the arg is not a list. ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2006-12-02 16:53 Message: Logged In: YES user_id=588346 Originator: YES Oops, it's actually trigexpand( [ atan(sin(a)/cos(a)) ] ) => [ atan(tan(a)) ] (UNSIMPLIFIED!) It doesn't simplify atan of tan, but it does preserve the list... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1607567&group_id=4933 |