# Nesting multiple functions of multiple variables

I was wondering how one would go about nesting multiple functions of, say, two variables. The problem comes from trying to implement the Chirikov standard map without using "for" cycles. I found a demonstration project that did it, but I couldn't figure out the code. I would appreciate any kind of help, thanks.

Just for the sake of information, the Chirikov standard map can be defined as

\begin{aligned} y' &= y + \varepsilon \sin(x) \\ x' &= x + y' \end{aligned}

-

## 1 Answer

There are more compact ways, but I wrote the following snippet so that you can easily see what's going on:

With[{ε = 1/10},
NestList[Apply[Function[{y, x}, {y + ε Sin[x],
x + y + ε Sin[x]}], #] &, N[{2, 3}, 20], 10]]

{{2.0000000000000000000, 3.0000000000000000000},
{2.0141120008059867222, 5.0141120008059867222},
{1.9186294124134132492, 6.9327414132193999714},
{1.9791127093468275926, 8.911854122566227564},
{2.0281854013777844485, 10.940039523944012013},
{1.9283395672481502054, 12.868379091192162218},
{1.9580834052997931408, 14.826462496491955359},
{2.0352528281815771916, 16.861715324673532550},
{1.9438238102007648290, 18.805539134874297379},
{1.939423552755534905, 20.744962687629832284},
{2.034201057221580261, 22.779163744851412546}}


That gives a list of iterates. If you need only the last one, replace NestList[] with Nest[]. If you want to visualize these iterates as points, use either ListPlot[] or ListLinePlot[]:

With[{ε = 1/50},
ListPlot[NestList[Apply[Function[{y, x}, {y + ε Sin[x],
x + y + ε Sin[x]}], #] &, N[{1, -1}, 20], 10]]]


-
Perfect! Thanks! – Andy Jun 3 '12 at 12:54