Re: Problem with Expand[Expr, Trig ->True]

• To: mathgroup at smc.vnet.net
• Subject: [mg12727] Re: Problem with Expand[Expr, Trig ->True]
• From: Daniel Lichtblau <danl>
• Date: Thu, 4 Jun 1998 02:52:13 -0400
• Organization: Wolfram Research, Inc.
• References: <6l2qrg\$e2u@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```S. Sankaranarayanan wrote:
>
> Hi
>
> I was trying to use Expand[Expr, Trig ->True] for an  example given in
> Mathematica book, second edition. It does not  seem to work.
>
> n[24]:= Expand[Sin[x]^2+Sin[2x]^2]
>
>                2           2
> Out[24]= Sin[x]  + Sin[2 x]
>
> Expand[%,Trig ->True]
>
> It gives likes this:
>                    2         4         2                             4
>              Cos[x]    Cos[x]    Sin[x]            2       2   Sin[x]
> Out[25]= 1 - ------- - ------- + ------- + 3 Cos[x]  Sin[x]  - -------
>                 2         2         2                             2
>
> But it is supposed to give
>
> 1    - Cos[2 x] - Cos[4 x]
>      -----------------------
>                     2
> But if I use
>
> TrigReduce[Sin[x]^2 + Sin[2 x]^2]
>
> It gives the needed answer.
>
>          2 - Cos[2 x] - Cos[4 x]
> Out[23]= -----------------------
>                     2
>
> Responses will be very much appreciated.
>
> Thanks,
>
> Sankar

Sounds like you are using the version 2 reference and the version 3
product. The old Expand[...,Trig->True] became TrigReduce,
Expand[...,Trig->True] is (at least almost always) equivalent to
TrigExpand, which is similar to but faster and more general than the
old Trigonometry`TrigReduce from the Algebra`Trigonometry standard
package. All quite clear, no?

Sorry for the change of names, but once you use the up-to-date
documentation I think you will find the new functionality to be alot
better in terms of speed and reliability. The old package code relied
on rule-based programming that was slow, got into deep recursion, did
not handle hyperbolics, etc. Much improved now.

Roughly speaking, TrigExpand will expand sums and rational products of
trig arguments, e.g. Cos[a+2*b]. TrigReduce will attempt to group
arguments together to reduce powers of trigs, effectively undoing
TrigExpand.

In[3]:= ee = Cos[a+2*b];

In[4]:= TrigExpand[ee] // InputForm
Out[4]//InputForm= Cos[a]*Cos[b]^2 - 2*Cos[b]*Sin[a]*Sin[b] -
Cos[a]*Sin[b]^2

In[5]:= TrigReduce[%]
Out[5]= Cos[a + 2 b]

Of course trigs do not have unique forms (all those identities), hence

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Efficient way to merge lists--Programming help
• Next by Date: Re: who has written a BEM code for an airfoil?
• Previous by thread: Problem with Expand[Expr, Trig ->True]
• Next by thread: Re: How to get PostScript file in text mode.Path: monon.wolfram.com!paulh