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...
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.
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...
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.
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....
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 ] (?)
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?
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?
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.
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.
Logged In: YES
user_id=28849
Originator: NO
I'm applying your fix. Could you send some examples where your original fix didn't work. I'd like them for regression tests.
Logged In: YES
user_id=588346
Originator: YES
Here is an example of one handled by the new and not the old code:
trigreduce([sin(x)^2]) => [ (2-2*cos(2*x))/4 ] WRONG
=> [ (1-cos(2*x))/2 ] Fixed
Also, leaving the bag unsimplified is more correct in general, though it doesn't currently matter. It will matter if (for example) sets get added to mbagp.
Logged In: YES
user_id=28849
Originator: NO
Additional test added, so closing bug.