On 12/28/07, Rupert Swarbrick <rswarbrick at googlemail.com> wrote:
> I think I've fixed bug 580721. Currently, simp-%tan and simp-%cot look
> at form and one of the attempted simplifications is that if form is
> tan(u) or cot(u) where u is linear in %pi (as measured by linearp), it
> calls %piargs-tan/cot.
Rupert, I've applied the patch for src/trigi.lisp to my local sandbox
and it seems to work OK and also doesn't change any of the existing
test cases, so that's good. However, I see that you have hooked the
argument reduction into SIMP-%TAN so it happens when %piargs = true
which is the default. On the other hand sin and cos with the same
arguments are not reduced by default, but rather by trigexpand.
I am inclined to recommend that tan and cot are not reduced
automatically in this case, but if you want to argue for making the
reduction automatic, I might change my mind.
> 1) The code wasn't documented at all: does anyone know if I'm right
> about what everything does?
I don't know much specifically about the trig code so I can't comment
on this, I'm afraid.
> 2) I never did quite work out what one of the tests in %piargs-tan/cot
> actually did: there's a comment beginning I _think_ on line 593. Anyone
> know?
See (1).
> 3) I defined some utility functions, specifically filter-sum,
> constant-linear-p and has-constant-linear-term. Do any of them already
> exist in maxima and I just didn't find them? If not, where should they
> go? In particular filter-sum looks like it might be more generally
> applicable.
I wouldn't be surprised if such functions have been written repeatedly
over the years, but I don't know of any. A duplicate of this kind isn't
much of a problem, as long as it solves at least the problem you have
in mind, and doesn't cause trouble for existing stuff.
You might take a look at the code in trigexpand which handles
sin(%pi/2 + x*%pi) --> cos(%pi*x) since it is presumably doing the same thing.
> 4) If this patch is good, should I also write a test in the test_suite?
Yes, that's always a good idea.
Thanks for your help,
Robert Dodier