[Date Index]
[Thread Index]
[Author Index]
Trig Functions with arguments = Integer * Pi
*To*: mathgroup at christensen.cybernetics.net
*Subject*: Trig Functions with arguments = Integer * Pi
*From*: olness at phyvms.physics.smu.edu (Fredrick Olness (214) 768-2500 or -2495, Fax -4095)
*Date*: Wed, 26 Oct 1994 12:36:57 -0500
> Fedor G. Pikus WRITES:
> I need to declare some variables as integer, so that the trig functions
> would be simplified. I have Declare package from MathSource,
> but it does not help: I declare n to be integer, and Sin[n Pi] stays
> as it is.
=================================================================
Fedor,
I have attached a solution below. I have also included the case of
the Cos[n Pi] which may be of interest.
You may wish to practice on a sample function like sin[] or cos[]
(lowercase) before you start redefining system functions.
Fred Olness
=================================================================
IntegerQ[n] ^= True;
?n
Global`n
IntegerQ[n] ^= True
Unprotect[Sin];
Sin[n_?IntegerQ Pi] := 0;
Protect[Sin];
{Sin[ n Pi],Sin[ 2 n Pi],Sin[ 2 Pi],Sin[ j Pi]}
{0, Sin[2 n Pi], 0, Sin[j Pi]} (*Note, the 2nd did not simplify*)
Unprotect[Cos];
Cos[n_?IntegerQ Pi] := (-1)^n;
Protect[Cos];
{Cos[ n Pi],Cos[ 2 n Pi],Cos[ 2 Pi],Cos[ 3 Pi]}
n
{(-1) , Cos[2 n Pi], 1, -1}
=================================================================
Fredrick I. Olness
SMU Mail: Department of Physics
Fondren Science Bldg.
Southern Methodist University
Dallas, TX 75275
Phone: (214) 768-2500 (SMU Office)
(214) 768-2495 (SMU Secretary)
(214) 768-4095 (SMU FAX)
Internet: Olness at phyvms.physics.smu.edu (129.119.200.74)
Olness at mail.physics.smu.edu
Prev by Date:
**Axes Positioning in Plots**
Next by Date:
**Administration**
Previous by thread:
**Axes Positioning in Plots**
Next by thread:
**Administration**
| |