# 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}

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

The correct way to draw some orbits for this map:

  With[{ε = 1.023, icv = Union[Table[{m, m}, {m, 0, 6, 0.1}], {{1.63, 0.41},
{5.23, 2.58}, {5.33, 2.64}, {5.43, 2.64}, {5.53, 2.64}, {5.63, 2.64},
{5.83, 2.64}, {5.25, 5.94}, {4.6, 5.3}, {4.6, 5.13},
{4.56, 4.85}, {4.6, 5.5}, {4.7, 4.3}, {1.5, 4.25}, {5, 2.2},
{1.57, 4.57}, {5.24, 2.17}, {1.68, 1.01}, {0.34, 3.31},
{5.4, 1.2}, {0.97, 5.01}, {4.69, 5.48}, {4.59, 5.02},
{2.42, 5.42}, {5.06, 5.92}, {5.03, 5.96}, {5.58, 5.93},
{5.68, 5.98}, {6.02, 5.33}, {5.94, 5.26}, {4.78, 3.13},
{4.8, 1.65}, {4.79, 1.44}, {1.03, 5.92}, {4.17, 4.4},
{4.18, 4.56}, {4.18, 4.66}, {4.62, 5.22}, {2.86, 1.41},
{3.12, 4.49}, {3.12, 4.59}, {2.36, 1.25}, {0.99, 0.86},
{2.71, 4.92}, {2.33, 0.96}, {3.39, 1.13}, {2.32, 1.13},
{2.98, 1.24}, {2.97, 1.28}, {2.72, 0.92}, {4.41, 4.53},
{2.93, 4.13}, {2.12, 2.27}, {3.95, 5.09}, {3.4, 1.07},
{2.78, 0.98}, {2.81, 0.98}, {3.19, 1.05}, {3.43, 4.8},
{1.6, 0.798}, {2.56, 4.36}, {5.2, 5.73}, {5.01, 4.87},
{4.68, 4.66}, {4.83, 4.63}, {5.61, 5.94}, {1, 0.81},
{0.58, 0.29}, {1.07, 0.53}, {0.87, 5.99}, {3.09, 4.98},
{2.43, 1.41}, {2.55, 4.56}, {3.12, 4.7}, {4.42, 4.58},
{5.28, 5.45}, {4.02, 4.92}, {3.84, 4.87}, {4.42, 4.57},
{0.41, 5.6}, {4.49, 4.96}, {0.95, 0.86}, {3.17, 4.19},
{0.77, 5.09}, {1.58, 5.99}, {1.18, 4.03}}]},
ListPlot[Table[NestList[Apply[Function[{y, x},
{Mod[y + ε Sin[x], 2 π], Mod[x + y + ε Sin[x], 2 π]}], #] &,
N[{icv[[i, 1]], icv[[i, 2]]}, 100], 3000], {i, 1, Length[icv]}],
PlotRange->{{0,2 π},{0,2 π}},
PlotStyle -> {{Opacity[0.25]}}, Frame -> True, FrameStyle -> Black,
Axes -> False, PlotRange -> All, AspectRatio -> 1]]


The orbits:

Interactively: