Prev: Haldeman-Ramanujan quintuplets
Next: FERMATISTS -- HERE IS WHY INFINITY VALUE IS (000.) Decimal point on the left is prime!
From: Robert Kaufman on 27 Jun 2010 15:15 Hi! Would someone please show me how to iterate a function in Maple. Respectfully, Robert Kaufman
From: [Mr.] Lynn Kurtz on 27 Jun 2010 22:55 On Sun, 27 Jun 2010 19:15:10 EDT, Robert Kaufman <Yearachmeel(a)verizon.net> wrote: >Hi! > > Would someone please show me how to iterate a function >in Maple. > >Respectfully, > >Robert Kaufman This may not be the most elegant thing but it seems to work (Maple 13) One of the pros around here will probably find something slicker. Iterates cos(x) 5 times f := x->cos(x); iterate := proc (f, n) local k, a; a[1] := f; for k from 1 to n do a[k+1] := `@`(f, a[k]) end do; a[n] end proc; f5 := iterate(f, 5); f5(x); http://math.asu.edu/~kurtz
From: [Mr.] Lynn Kurtz on 28 Jun 2010 00:36 On Sun, 27 Jun 2010 19:55:04 -0700, "[Mr.] Lynn Kurtz" <kurtz(a)asu.edu.invalid> wrote: >This may not be the most elegant thing but it seems to work (Maple 13) >One of the pros around here will probably find something slicker. > Here's a better iterate procedure: iterate2 := proc (f, n) local k, a; a := f; for k from 1 to n-1 do a := f@a end: a; end; http://math.asu.edu/~kurtz
From: Robert Kaufman on 28 Jun 2010 03:50 Hi! Thank you very much for your reply. It motivated me to find another simple solution, Respectfully, Robert Kaufman
From: TCL on 28 Jun 2010 09:40
On Jun 28, 12:36 am, "[Mr.] Lynn Kurtz" <ku...(a)asu.edu.invalid> wrote: > On Sun, 27 Jun 2010 19:55:04 -0700, "[Mr.] Lynn Kurtz" > > <ku...(a)asu.edu.invalid> wrote: > >This may not be the most elegant thing but it seems to work (Maple 13) > >One of the pros around here will probably find something slicker. > > Here's a better iterate procedure: > > iterate2 := proc (f, n) > local k, a; > a := f; > for k from 1 to n-1 > do a := f@a > end: > a; > end; > > http://math.asu.edu/~kurtz Your code does not work for my Maple 9. Instead the following works: iterate2 := proc (n) local k, a; a := ?; for k from 1 to n do a := f(a) end: a; end; (Replace the ? by the initial value of a) -TCL |