Re: variable declarations in mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg7415] Re: [mg7373] variable declarations in mathematica?
- From: jpk at max.mpae.gwdg.de
- Date: Sat, 31 May 1997 15:07:24 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> I'm trying to get Mathematica 3.0 to treat the variable n as an integer during the > simplification process. I spent several hours with the mathematica handbook, but have not yet > found the solution. > > What I want is to somehow DEFINE n as an integer so that for instance: > > Gamma[ n ] simplifies to: ( n - 1 )! or, > > ( 2 n - 1 )!! > Gamma[ n + 1/2 ] simplifies to: ------------- . Sqrt[ Pi ] > 2^n > > It cannot be hard... > > Thanks. > > Bas ten Hoope > > Hi here is one solution First say n is an integer n/: IntegerQ[n]:=True Than say that Gamma[_?IntegerQ] is (n-1)! and add some rules for sums and products of integers Unprotect[Gamma,IntegerQ] IntegerQ[a_+b_]:=IntegerQ[a] && IntegerQ[b] IntegerQ[a_*b_]:=IntegerQ[a] && IntegerQ[b] Gamma[n_?IntegerQ]:=(n-1)! Protect[Gamma,IntegerQ] and Gamma[n] is simplifyed as You want. Hope that helps Jens