       Re: Wrestling with Mathematica on Trig Simplification

• To: mathgroup at smc.vnet.net
• Subject: [mg32392] Re: Wrestling with Mathematica on Trig Simplification
• Date: Fri, 18 Jan 2002 00:17:38 -0500 (EST)
• References: <a1bllp\$bcb\$1@smc.vnet.net> <a1qrr1\$9ee\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Dana,

Your method seems very elegant to me.  In fact if a and b (or any
other variables are assumed to be real you can get it to very nicely
simplify by using complex expand.

A comparison is below.  I also used some of the ideas from David
Park's previous posts to this question.

In:=
oldrule[expr_] :=
expr/. a_ Sin[t_] + b_ Cos[t_] -> Abs[a + b I]Cos[t - Arg[b + I a]]

In:=
oldrule[2 Cos[t]+3 Sin[t]]
oldrule[a Cos[t]+b Sin[t]]

Out=
Sqrt*Cos[t - ArcTan[3/2]]

Out=
Abs[I*a + b]*Cos[t - Arg[a + I*b]]

In:=
newrule[expr_] :=
ComplexExpand[
expr/. a_ Sin[t_] + b_ Cos[t_] -> Abs[a + b I]Cos[t - Arg[b + I
a]] ,
TargetFunctions->{Re,Im}]

In:=
newrule[2 Cos[t]+3 Sin[t]]
newrule[a Cos[t]+b Sin[t]]

Out=
Sqrt*Cos[t - ArcTan[3/2]]

Out=
Sqrt[a^2 + b^2]*Cos[t - ArcTan[a, b]]

"Dana" <ng_only at hotmail.com> wrote in message news:<a1qrr1\$9ee\$1 at smc.vnet.net>...
> I am really new at this, so I am probably way off.  Taking your excellent
> idea, perhaps you could rewrite it as the following rule??
>
> myrule = a_ Sin[t_] + b_ Cos[t_] ->  Abs[a + b I]Cos[t - Arg[b + I a]]
>
> As an example:
>
> In:=
> 3Sin[1/2]+4Cos[1/2]/.myrule
>
> Out=
> 5*Cos(1/2 - ArcTan(3/4))
>
> On could include this following in Mathematica 4 to set a & b to Reals.
> Element[{a, b}, Reals]
>
> - - - - - - - - - - - - - - - - - - - - - -

```

• Prev by Date: Re: Solving problem
• Next by Date: MathML Conference: Final Call for Papers
• Previous by thread: Re: Wrestling with Mathematica on Trig Simplification
• Next by thread: Re: Re: Wrestling with Mathematica on Trig Simplification