Re: Question: how to get Sin[n*Pi]=0 (n integer)

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg1960] Re: Question: how to get Sin[n*Pi]=0 (n integer)
• From: Bob Hanlon <hanlon at pafosu2.hq.af.mil>
• Date: Sun, 27 Aug 1995 23:23:38 -0400

```>  Newsgroups: comp.soft-sys.math.mathematica
>  From: izovko at dominis.phy.hr (Ilija I Zovko)
>  Subject: Question: how to get Sin[n*Pi]=0 (n integer)
>  Date: Fri, 25 Aug 1995 04:08:30 GMT
>
>  Hi,
>
>  How can one tell Mathematica to simplify Sin[n Pi]=0 or
>  Cos[n Pi]=(-1)^n and similar kind of stuff.
>
>  Also, how does one tell it "A" & "B" are matrices so it doesn't
>  commute them (AB.not equal.BA).
>
>  Thanks.
>  )
>
>  --
>  Ilija I Zovko
>  izovko at phy.hr

Try this.

Bob Hanlon
_______________

(*  Extend definitions of standard functions *)
Unprotect[Sin, Csc, Cos, Sec, Tan, Cot, IntegerQ, EvenQ, OddQ];

Clear[Sin, Cos, Tan, IntegerQ, EvenQ, OddQ];

IntegerQ[x_?IntegerQ y_?IntegerQ + z_:0] := IntegerQ[z];

EvenQ[x_ y_ + z_:0] := ( ( EvenQ[x] || EvenQ[y] ) && EvenQ[z] ) ||
( OddQ[x] && OddQ[y] && OddQ[z] );

OddQ[x_ y_ + z_:0] := ( ( EvenQ[x] || EvenQ[y] ) && OddQ[z] ) ||
( OddQ[x] && OddQ[y] && EvenQ[z] );

Sin[ n_?EvenQ Pi/2 ] = 0;

Sin[ n_?OddQ Pi/2 ] := ((-1)^Expand[(n-1)/2]) /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Sin[ n_?EvenQ Pi/2 + x_ * a_. ] := (-1)^(n/2) Sin[a x];

Sin[ n_?OddQ Pi/2 + x_ * a_. ] := ((-1)^Expand[(n-1)/2]) Cos[a x] /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Sin[ n_?IntegerQ Pi ] = 0;

Sin[ n_?IntegerQ Pi + x_ * a_. ] :=
Which[  EvenQ[n], Sin[a x], OddQ[n], -Sin[a x],
True, (-1)^n Sin[a x] /. (-1)^(c_ d_?OddQ) ->
(-1)^c ];

Csc[ n_?EvenQ Pi/2 ] = ComplexInfinity;

Csc[ n_?OddQ Pi/2 ] := ((-1)^Expand[(n-1)/2]) /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Csc[ n_?EvenQ Pi/2 + x_ * a_. ] := (-1)^(n/2) Csc[a x];

Csc[ n_?OddQ Pi/2 + x_ * a_. ] := ((-1)^Expand[(n-1)/2]) Sec[a x] /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Csc[ n_?IntegerQ Pi ] = ComplexInfinity;

Csc[ n_?IntegerQ Pi + x_ * a_. ] :=
Which[  EvenQ[n], Csc[a x], OddQ[n], -Csc[a x],
True, (-1)^n Csc[a x] /. (-1)^(c_ d_?OddQ) ->
(-1)^c ];

Cos[ n_?EvenQ Pi/2 ] = (-1)^(n/2);  Cos[ n_?OddQ Pi/2 ] := 0;

Cos[ n_?EvenQ Pi/2 + x_ * a_. ] := (-1)^(n/2) Cos[a x];

Cos[ n_?OddQ Pi/2 + x_ * a_. ] := ((-1)^Expand[(n-1)/2]) Sin[a x] /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Cos[ n_?IntegerQ Pi ] :=
Which[  EvenQ[n], 1, OddQ[n], -1,
True, (-1)^n /. (-1)^(c_ d_?OddQ) -> (-1)^c ];

Cos[ n_?IntegerQ Pi + x_ * a_. ] :=
Which[  EvenQ[n], Cos[a x], OddQ[n], -Cos[a x],
True, (-1)^n Cos[a x] /. (-1)^(c_ d_?OddQ) ->
(-1)^c ];

Sec[ n_?EvenQ Pi/2 ] = (-1)^(n/2);

Sec[ n_?OddQ Pi/2 ] := ComplexInfinity;

Sec[ n_?EvenQ Pi/2 + x_ * a_. ] := (-1)^(n/2) Sec[a x];

Sec[ n_?OddQ Pi/2 + x_ * a_. ] := ((-1)^Expand[(n-1)/2]) Csc[a x] /.
(-1)^(c_ + d_?EvenQ) -> (-1)^c;

Sec[ n_?IntegerQ Pi ] :=
Which[  EvenQ[n], 1, OddQ[n], -1,
True, (-1)^n /. (-1)^(c_ d_?OddQ) -> (-1)^c ];

Sec[ n_?IntegerQ Pi + x_ * a_. ] :=
Which[  EvenQ[n], Sec[a x], OddQ[n], -Sec[a x],
True, (-1)^n Sec[a x] /. (-1)^(c_ d_?OddQ) ->
(-1)^c ];

Tan[ n_?EvenQ Pi/2 ] = 0; Tan[ n_?OddQ Pi/2 ] = ComplexInfinity;

Tan[ n_?IntegerQ Pi + x_ * a_. ] := Tan[a x];

Tan[ n_?IntegerQ Pi ] = 0;

Cot[n_?EvenQ Pi/2] = ComplexInfinity;  Cot[n_?OddQ Pi/2] = 0;

Cot[ n_?IntegerQ Pi ] = ComplexInfinity;

Protect[Sin, Csc, Cos, Sec, Tan, Cot, IntegerQ, EvenQ, OddQ];

(* Define m and n as integers *)
m/: IntegerQ[m] = True;  n/: IntegerQ[n] = True;

(* Define keven as an even integer *)
keven/: IntegerQ[keven] = True;  keven/: EvenQ[keven] = True;

(* Define kodd as an odd integer *)
kodd/: IntegerQ[kodd] = True;  kodd/: OddQ[kodd] = True;

TableForm[ Partition[Flatten[{ f[n Pi], f[keven Pi], f[kodd Pi],
f[n Pi/2], f[keven Pi/2], f[kodd Pi/2] } /.
{ {f -> Sin}, {f -> Cos}, {f -> Tan} } ], 3],
TableSpacing -> {1, 6} ]

0              0                0

n Pi
Sin[----]                           -(1/2) + kodd/2
2         0                (-1)

n
(-1)           1                -1

n Pi
Cos[----]          keven/2
2         (-1)             0

0              0                0

n Pi
Tan[----]
2         0                ComplexInfinity

test = {comment, f[a b Pi], f[a b Pi + c x] } /.
{ {comment -> "integer:", a -> n, b -> m},
{comment -> "one even:", a -> 2n, b -> m},
{comment -> "one odd:", a -> 2n+1, b -> m},
{comment -> "both odd:", a -> 2n+1, b -> 2m+1} };

TableForm[test /. f -> Sin, TableSpacing -> {2, 9} ]

m n
integer:          0         (-1)    Sin[c x]

one even:         0         Sin[c x]

m
one odd:          0         (-1)  Sin[c x]

both odd:         0         -Sin[c x]

TableForm[test /. f -> Cos, TableSpacing -> {2, 6} ]

m n          m n
integer:       (-1)         (-1)    Cos[c x]

one even:      1            Cos[c x]

m            m
one odd:       (-1)         (-1)  Cos[c x]

both odd:      -1           -Cos[c x]

test = {comment, f[a b Pi/2], f[a b Pi/2 + c x] } /.
{ {comment -> "integer:", a -> n, b -> m},
{comment -> "one even:", a -> 2n, b -> m},
{comment -> "both even:", a -> 2n, b -> 2m},
{comment -> "one odd:", a -> 2n+1, b -> m},
{comment -> "both odd:", a -> 2n+1, b -> 2m+1} };

TableForm[test /. f -> Sin, TableSpacing -> {2, 4} ]

m n Pi                 m n Pi
Sin[------]            Sin[------ + c x]
integer:            2                      2

m n
one even:     0                      (-1)    Sin[c x]

both even:    0                      Sin[c x]

m (1 + 2 n) Pi         m (1 + 2 n) Pi
Sin[--------------]    Sin[-------------- + c x]
one odd:                2                      2

m + n                  m + n
both odd:     (-1)                   (-1)      Cos[c x]

TableForm[test /. f -> Cos, TableSpacing -> {2, 4} ]

m n Pi                 m n Pi
Cos[------]            Cos[------ + c x]
integer:            2                      2

m n                    m n
one even:     (-1)                   (-1)    Cos[c x]

both even:    1                      Cos[c x]

m (1 + 2 n) Pi         m (1 + 2 n) Pi
Cos[--------------]    Cos[-------------- + c x]
one odd:                2                      2

m + n
both odd:     0                      (-1)      Sin[c x]

```

• Prev by Date: Re: Q: ArcTan[ Tan[ x ] ] = x
• Next by Date: MacTCP connection
• Previous by thread: Re: Question: how to get Sin[n*Pi]=0 (n integer)
• Next by thread: Re: Question: how to get Sin[n*Pi]=0 (n integer)