       Re: nested derivatives

• To: mathgroup at smc.vnet.net
• Subject: [mg93119] Re: nested derivatives
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Mon, 27 Oct 2008 03:12:51 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <ge14fc\$9g2\$1@smc.vnet.net>

```Huub Mooren wrote:

> How do I enter the following recursive function in Mathematica:
> t[n]=(1/y')*t'[n-1],
> with n the index
> t=x
> y is some function of x

Since t[n] does not explicitly depends on x, we must write t'[n-1] as
D[t[n-1],x].

Having said that, we can define our function either using an explicit
recursive definition (see In, note that the definition also includes
some test on the argument and use memoization  for computational
efficiency ), or we can use higher-level functions such as *Nest* 
(see In, which use a pure function for its recursive call).

In:=

t = x;
t[n_Integer?Positive] := t[n] = 1/y'[x] D[t[n - 1], x]

Table[{n, t[n]}, {n, 4}] //
TableForm[#, TableHeadings -> {None, {"n", "t[n]"}}] & // OutputForm

Out//OutputForm=

n   t[n]

1     1
-----
y'[x]

2     y''[x]
-(------)
3
y'[x]

3           2    (3)
3 y''[x]    y   [x]
--------- - -------
4          3
y'[x]      y'[x]
-------------------
y'[x]

2    (3)
3 y''[x]    y   [x]
y''[x] (--------- - -------)
4          3
y'[x]      y'[x]
(-(----------------------------) +
2
y'[x]

3             (3)       (4)
-12 y''[x]    9 y''[x] y   [x]   y   [x]
(----------- + ---------------- - -------) / y'[x]) / y'[x]
5                4             3
4          y'[x]            y'[x]         y'[x]

In:=

tt[n_Integer?Positive] := Nest[1/y'[x] D[#, x] &, x, n]

Table[tt[n] == t[n], {n, 4}]

Out= {True, True, True, True}

Regards,
- Jean-Marc

http://en.wikipedia.org/wiki/Memoization

 "Functions That Remember Values They Have Found"
http://reference.wolfram.com/mathematica/tutorial/FunctionsThatRememberValuesTheyHaveFound.html

 "Applying Functions Repeatedly"
http://reference.wolfram.com/mathematica/tutorial/ApplyingFunctionsRepeatedly.html

```

• Prev by Date: Re: Is there a simple way to transform 1.1 to 11/10
• Next by Date: Re: ODE solution problem
• Previous by thread: Re: nested derivatives