RE: Help! Sin[n Pi] (n Integer)
- To: mathgroup at smc.vnet.net
- Subject: [mg9015] RE: [mg8942] Help! Sin[n Pi] (n Integer)
- From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
- Date: Wed, 8 Oct 1997 00:05:12 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Greg Anderson wrote:
----------
|Does anyone know if there's a way to specify that a variable is an
|integer?
|
| Sin[n Pi] or Cos[(2n+1)/2 Pi] come
| up constantly. I can dispose of them with replacement rules, but I was
| wondering if there's a way to "tag" n as an integer so that Mma will
| automatically kill the Sin and Cos terms later in the derivations.
|
The following will do what you want:
In[1]:= Unprotect[Sin, Cos];
Sin[n_?IntegerQ * Pi]:=0
Cos[n_?OddQ/2 * Pi]:=0
Cos[(m_?EvenQ * n_?IntegerQ + 1)/2 Pi]:=0
Protect[Sin, Cos];
In[4]:= IntegerQ[n]^=True;
OddQ[j]^=True;
In[5]:= {Sin[n Pi], Cos[(2 n + 1)/2 Pi], Cos[ j / 2 * Pi], Cos[a /2 * Pi]}
Out[5]= { 0, 0, 0, Cos[a Pi/2] }
Notice: Cos[a/2 * Pi] doesn't simplify because nothing is known about (a).
I hope WRI will include the rules above and hundreds of other in a later
version.
Ted Ersek
ersek_ted%pax1a at mr.nawcad.navy.mil