MathGroup Archive 1998

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

Search the Archive

Integer declaration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13014] Integer declaration
  • From: "Le Van Tri" <lvtri at cs.uwm.edu>
  • Date: Tue, 30 Jun 1998 00:26:11 -0400
  • Organization: University of Wisconsin - Milwaukee
  • Sender: owner-wri-mathgroup at wolfram.com

Dear mathematica gurus,
I have seen several times in this news group someone needs to do
simplification
with integers. The following might help you to do it.

Unprotect[IntegerQ];
IntegerQ[m_+n_]/;IntegerQ[m]&&IntegerQ[n]=True;
IntegerQ[m_*n_]/;IntegerQ[m]&&IntegerQ[n]=True;
IntegerQ[m_^n_]/;IntegerQ[m]&&IntegerQ[n]&&NonNegative[n]=True;

Unprotect[Sin,Cos];
Sin[m_*Pi]/;IntegerQ[m]=0;
Cos[m_*Pi]/;IntegerQ[m]=1;
Sin[m_*Pi+x_]/;IntegerQ[m]=Sin[x];
Cos[m_*Pi+x_]/;IntegerQ[m]=Cos[x];
...

Ofcourse, you could add more simplification rules for your other
functions as well. I think this will work in many situations. How ever,
I dont know if there is a solution for the following situation:
  IntegerQ[m]=True;
  IntegerQ[n*n]=True;
  Should IntegerQ[m*(n-1)*(n+1)*(n^2+1)] be True? Does anyone have some
idea on this?

Regards,
Tri.




  • Prev by Date: Re: How to declare Integers?
  • Next by Date: Re: Converting from StandarForm to Text
  • Previous by thread: Importing external grid file to do contour plot
  • Next by thread: Barycentric Coordinates