MathGroup Archive 1998

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

Search the Archive

Re: TELLING PROGRAM THAT A VARIABLE IS AN INTEGER



>...
>As it stands right now, you have to do these things manually and decide
>that n is an integer yourself and then define Sin[n Pi]->0.  What would
>be really nice is if you could do something like Sin[_Integer Pi]->0
>and have that kind of a pattern stick, but that code doesn't work and I
>don't know of any way to do that kind of thing without a lot of
>programming.
>...

You could make the following definitions:

Unprotect[Sin];
Sin[m_ \[Pi]]:=0/;IntegerQ[m]\[Equal]True Protect[Sin];

IntegerQ[n]^=True

Then evaluate

Sin[n \[Pi]]

to obtain

0

======================================================

Stephen P Luttrell
luttrell@signal.dra.hmg.gb
Adaptive Systems Theory                           01684-894046 (phone)
Room EX21, DERA                                    01684-894384 (fax)
Malvern, Worcs, WR14 3PS, U.K.
http://www.dra.hmg.gb/cis5pip/Welcome.html




  • Prev by Date: Installing Linux version with Win 95/NT version licensed
  • Next by Date: Re: Re: Eigenvalues
  • Prev by thread: Re: TELLING PROGRAM THAT A VARIABLE IS AN INTEGER
  • Next by thread: Can You Change Domain in ListContourPlot?