MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Wrestling with Mathematica on Trig Simplification

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32392] Re: Wrestling with Mathematica on Trig Simplification
  • From: adam.smith at hillsdale.edu (Adam Smith)
  • 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[1]:=
oldrule[expr_] := 
  expr/. a_ Sin[t_] + b_ Cos[t_] -> Abs[a + b I]Cos[t - Arg[b + I a]] 


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

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

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

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

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

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

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

Adam Smith


"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[5]:=
> 3Sin[1/2]+4Cos[1/2]/.myrule
> 
> Out[5]=
> 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