[Date Index]
[Thread Index]
[Author Index]
Re: Trying to recursively define a double factorial
*To*: mathgroup at smc.vnet.net
*Subject*: [mg126526] Re: Trying to recursively define a double factorial
*From*: Dana DeLouis <dana01 at me.com>
*Date*: Thu, 17 May 2012 04:09:10 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
> I wanna make a recursive function of this double factorial without If(and other similar statements).
Hi. If I understand your question, here is one possible idea:
f[0]=f[1]=1;
f[n_Integer?Positive] := f[n] = n*f[n-2]
f[11]==11!!
True
f[12]==12!!
True
Information[ f ]
f[0]=1
f[1]=1
f[2]=2
f[3]=3
f[4]=8
f[5]=15
f[6]=48
f[7]=105
f[8]=384
f[9]=945
f[10]=3840
f[11]=10395
f[12]=46080
f[n_Integer]:=f[n]=n f[n-2]
If you meant to use RSolve, perhaps an alternative might be:
equ={
a[0]==1,
a[1]==1,
a[n]==n*a[n-2]
};
// This is a little complicated because it doesn't know if n is odd/even
z=FullSimplify[RSolve[equ,a[n],n]] [[1,1,-1]]
(2^(1/2 (-3+n)) (2-2 (-1)^n+(1+(-1)^n) Sqrt[2 \[Pi]]) Gamma[1+n/2])/Sqrt[\[Pi]]
One technique for the Even or Odd part might be:
// Even
Assuming[Mod[n,2]==0,FullSimplify[z]]
2^(n/2) Gamma[1+n/2]
// Odd
Assuming[Mod[n,2]==1,FullSimplify[z]]
(2^((1+n)/2) Gamma[1+n/2])/Sqrt[\[Pi]]
Test of Even...
12!! == 2^(n/2) Gamma[1+n/2] /. n->12
True
= = = = = = = = = = = =
HTH :>)
Dana DeLouis
Mac & Math 8
To understand recursion, one must first understand recursion
= = = = = = = = = = = =
On May 16, 4:23 am, Jorge Cantu <monsterb... at msn.com> wrote:
> My goal here is to define a recursive function for a double factorial. The domain of this function is the set of positive integers. For a positive even integer n the value DF[n] is the product of all positive even integers which are <n. For a positive odd integer n the value DF[n] is the product of all positive odd integers which are <n.
>
> I wanna make a recursive function of this double factorial without If(and other similar statements). Here is my work so far:
>
> Clear[MyF1, n];
> MyF1[1] = 1;
> MyF1[n_Integer] /; (n > 0) := MyF1[n] = n*MyF1[n - 1]
>
> Table[MyF1[k], {k, (*integer*), (*integer*)}]
>
> How do I do this?
Prev by Date:
**Re: Trying to recursively define a double factorial**
Next by Date:
**Maximisation question**
Previous by thread:
**Re: Trying to recursively define a double factorial**
Next by thread:
**Keep dialog input window open after button press**
| |