Re: How to declare Integers?
- To: mathgroup at smc.vnet.net
- Subject: [mg13017] Re: [mg12966] How to declare Integers?
- From: Sean Ross <seanross at worldnet.att.net>
- Date: Tue, 30 Jun 1998 00:26:14 -0400
- References: <199806280651.CAA24297@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Carlos Wexler wrote: > > How can one declare a variable to be integer in Mathematica? > > Let me just give an example: > > Integrate[Sin[m x]/Sin[x], {x,0,Pi}] > > is well behaved if one explicitly sets m=1,2,3,... BEFORE doing the > integral: > > In[1]:= Integrate[Sin[1 x]/Sin[x], {x,0,Pi}] Out[1]= Pi > > In[2]:= Integrate[Sin[2 x]/Sin[x], {x,0,Pi}] Out[2]= 0 > > but > > In[3]:= Integrate[Sin[m x]/Sin[x], {x,0,Pi}] Out[3]= Integrate::"idiv": > Integral of Csc[x] Sin[m x] does not converge on {0,Pi} > > Other examples include evaluation of Sin[m Pi], etc... > > I tried the following trick stated in the manual: > > In[4]:= m/: IntegerQ[m] = True > Out[4]= True > > but still Sin[m Pi] does not simplify to 0 nor does Mathematica figures > out that the integral above does converge in this case. > > How can one declare m to be integer? There has to be a way! In Maple it > is rather easy and the expected behavior is obtained. I cannot believe > that it is not possible to accomplish the same in Mathematica as well. > > Thanks!! > > Carlos > > ----------------------------------------------------------------- Carlos > Wexler | Dept. of Physics, Box 118440 > | University of Florida > | Gainesville, FL 32611-8440 > | Tel: (352) 392-7334 > wexler at phys.ufl.edu | FAX: (352) 392-0524 > ----------------------------------------------------------------- > > -- > > ----------------------------------------------------------------- In short, you can't. There is no variable typing in mathematica. The only way are work around patern matchings and transformation rules that are specific to each problem. For example, you can define n/;Sin[n x]==0 and similar ideas. This doesn't mean that the problems are insoluble, it just means that you will have to specify via transformation rules the behavior of an integer expression. There are several of us that have been trying to explain to Wolfram people what object oriented variable typing means, but they just play dense and claim that the whole area is so vague that they can't do it. Certainly the variable typing that you (and I) are after is radically different from the variable typing done by Fortran or C++, which is for purposes of memory allocation and interpretation.
- References:
- How to declare Integers?
- From: wexler@einstein.phys.ufl.edu (Carlos Wexler)
- How to declare Integers?