# Mathematica for Theoretical Physics by Gerd Baumann : Henonmap

I was following a solved problem from the book mentioned below on the Henon map. However, even after correcting that I still get an error on execution. I am unable to find the exact cause.

Mathematica for Theoretical Physics Classical Mechanics and Nonlinear Dynamics by  Gerd Baumann

Here is the code mentioned in the book.

JacobiMatrix[fun_List, vars_List] := Outer[D, fun, vars]

Clear[HenonMap]

HenonMap[{T_, W_}, α_] :=
Block[{}, {θ*Cos[2*π*α] - (W - θ^2)*
Sin[2*π*α], θ*
Sin[2*π*α] + (W - θ^2)*Cos[2*π*α]}]

JacobiMatrix[
HenonMap[{θ, W}, α], {θ, W}] // MatrixForm

JacobiMatrix[HenonMap[{θ, W}, α], {θ, W}] //
Det // Simplify

initial = Table[{i, 0, 0}, {i, 0.1, 0.84, 0.015}];

henonPlot = {};

Do[AppendTo[henonPlot,
ListPlot[NestList[HenonMap[#, 0.2114] &, initial[[k]], 255],
PlotStyle -> Hue[k/Length[initial]], Frame -> True,
AspectRatio -> 1, AxesLabel -> {"θ", "W"},
PlotRange -> {{-1, 1}, {-1, 1}}]], {k, 1, Length[initial]}]

• @Ghoster, You are right. There is nothing wrong. I misread it. I've edited my question Commented Nov 28, 2022 at 6:19

1. HenonMap[{T_, W_}, α_] uses T in args but θ in body
2. initial is 3D, should be 2D
JacobiMatrix[fun_List, vars_List] := Outer[D, fun, vars]

Clear[HenonMap]

HenonMap[{T_, W_}, α_] :=
Block[{}, {T*Cos[2*π*α] - (W - T^2)*
Sin[2*π*α], T*
Sin[2*π*α] + (W - T^2)*Cos[2*π*α]}]

JacobiMatrix[
HenonMap[{θ, W}, α], {θ, W}] // MatrixForm

JacobiMatrix[HenonMap[{θ, W}, α], {θ, W}] //
Det // Simplify

initial = Table[{i, 0}, {i, 0.1, 0.84, 0.015}];

henonPlot = {};

Do[AppendTo[henonPlot,
ListPlot[NestList[HenonMap[#, 0.2114] &, initial[[k]], 255],
PlotStyle -> Hue[k/Length[initial]], Frame -> True,
AspectRatio -> 1, AxesLabel -> {"θ", "W"},
PlotRange -> {{-1, 1}, {-1, 1}}]], {k, 1, Length[initial]}]

Show[henonPlot]


• Silly me. Thank you for pointing that out Commented Nov 28, 2022 at 4:53
• just one more query, Why is that single loop isn't plotting after the Do[...] as shown in book? Commented Nov 28, 2022 at 5:01
• Do doesn't not return values, in this code plots are appended to a list, you need to use Show to combine them and show. Using Table is more in WM style Show[Table[ListPlot[ ...], {k, 1, Length[initial]}]]
– I.M.
Commented Nov 28, 2022 at 6:06
• @user84456 That's a compatibility issue, *Plot functions in and before v5 automatically prints the graphic. See this post for more info: mathematica.stackexchange.com/a/47123/1871 Commented Nov 28, 2022 at 7:22
• @user84456 Which version of Baumann's book are you using? I just checked version 2 of the book, definitions of HenonMap and initial are both correct therein. Commented Nov 28, 2022 at 7:34