Maxima:Products and sums of trigonometric terms



On 11/1/07, Constantine Frangos <cfrangos at telkomsa.net> wrote:
>
>
> I have an expression which can be  either  a product of trigonometric
> terms
> or a sum of trigonometric terms, for example: expr = z1*z2 or expr = z1 +
> z2.
>
> (1) Is there a Maxima command that indicates whether expr is a product of
> terms or a sum of terms ?


op(expr) will return the top-level operator; args(expr) gives its arguments.
Thus, op(a+b/2) => "+"; args(a+b/2) => [a, b/2].

(2) In applying the built-in Maxima simplification functions trigsimp,
> trigreduce, trigrat, etc on products of terms, it seems that the map
> function
> has to be used to obtain the desired simplification (example below).
>
> Is there perhaps another approach ?


Well, that is inherent in their definition.  Trigreduce replaces all
products of trigs with sums of trigs and trigexpand does the opposite.  So
trigreduce(sin(x)*cos(x)) => sin(2*x)/2, while map(trigreduce,sin(x)*cos(x))
is sin(x)*cos(x), since the individual terms are not products of trigs.
There is no built-in function which tries to find the smallest expression,
but it sounds as though you're building it ... at which point it would no
doubt be useful to others!

            -s