[Date Index] [Thread Index] [Author Index]
Re: variable declarations in mathematica?
> 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