MathGroup Archive 2000

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

Search the Archive

Re: iterations, recursions and derivatives

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22574] Re: [mg22544] iterations, recursions and derivatives
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 11 Mar 2000 17:52:45 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On Thursday, March 9, 2000 3:53:41 PM, Andrzej Kozlowski wrote:

> on 3/9/00 9:24 AM, Otto Linsuain at linsuain+ at andrew.cmu.edu wrote:
>
>> 
>> Hello. I find it hard to define a sequence of functions recursively and
>> be able to differenciate them at the same time. For example
>> 
>> f[x_,1]:=x^2
>> 
>> Try to differentiate Derivative[1,0][f][2,1] will not work. Changing :=
>> for = doesn't help. Can do:
>> 
>> f[x_,1_]:=x^2    Notice the _ after the 1  (Kind of wierd, isn't it?)
>> 
>> Now, however, can differentiate: Derivative[1,0][f][2,1] works fine.
>> But cannot work recursions:
>> 
>> f[x_,m_]:= SomeOperation[f[x,m-1]]  confuses the recursion process. I
>> have tried defining
>> 
>> f[x_,m_]:=If[m==1,x^2,SomeOperation[f[x,m-1]], but the recursion again
>> crashes.
>> 
>> I have tried Which, Switch, Condition, Dt, D, etc, but to no avail.
>> When I can take the derivative, I can't update m to m+1.
>> 
>> Any suggestions? Thanks, Otto Linsuain.
>> 
>> 
>
>
> You do not explain clearly enough what you want to do. For example, is the
following satisfactory?
>
>
> In[1]:=
> f[1][x_] := x^2
>
> In[2]:=
> f[n_][x_] := Sin[f[n - 1][x^n]]
>
> In[3]:=
> Derivative[1][f[5]][x]
>
> Out[3]=
>      239      240           240                240
> 240 x    Cos[x   ] Cos[Sin[x   ]] Cos[Sin[Sin[x   ]]]
>  
>                    240
>   Cos[Sin[Sin[Sin[x   ]]]]
>

-- 
Forgot to add one thing (I am sure lots of others have already pointed this
out):
f[x_,1_]:=x^2  is simply f[x_,_]:=x^2, since Mathematica naturally
interprets 1_ as Times[1,Blank]. So it is not surprising that you can
differentiate but can't do recursion.



  • Prev by Date: Question
  • Next by Date: Suppressing display of LogPlots
  • Previous by thread: Re: iterations, recursions and derivatives
  • Next by thread: Re: iterations, recursions and derivatives