MathGroup Archive 2008

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

Search the Archive

Re: Problems with recursive function


hi daniel,

thanks four your help. that?s the missing information i was searching 
for. You?re right, it would be better, to store each intermediate value.

Kind regards from germany

frank

> Hi Frank,
> 
> if I understand correctly, you need to define a recursion with a stop 
> 
> criterion. You can do this by e.g.:
> 
> test[0,_]:=5;
> 
> test[n_,b_]:=test[n-1,b] b;
> 
> test[10,5]
> 
> if you have many calculations, it may be advantageously to store 
> 
> intermediate results:
> 
> test[n_,b_]:=test[n-1,b]=test[n-1,b] b;
> 
> hope this helps, Daniel
> 
> 
> 
> Frank Hechtner wrote:
> 
>> Dear Newsgroup,
> 
> 
>> I'm in trouble with a recursive function. the functios looks similar to 
> 
>> test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an 
> 
>> argument of test.
> 
>> for any calculation i need to tell mathematica the first value of the 
> 
>> function, e.g. test[0, 5]=5. The problem is the following: the first 
> 
>> object is independent of b. does anyone know a way to tell mathematica 
> 
>> the following thing:
> 
> 
>>   test[0,b]=5 => test[0]=5 regardless to b.
> 
> 
>> Thanks for your help.
> 
> 
>> Frank
> 
> 
> 
> 


  • Prev by Date: RE: Just primitive ColorFunction
  • Next by Date: Re: Filling problem in Plot3D
  • Previous by thread: Re: Problems with recursive function
  • Next by thread: REMINDER--Advanced Mathematica Summer School