[Date Index]
[Thread Index]
[Author Index]
Re: Arnold's Cat Map
*To*: mathgroup at smc.vnet.net
*Subject*: [mg5326] Re: [mg5314] Arnold's Cat Map
*From*: Allan Hayes <hay at haystack>
*Date*: Wed, 27 Nov 1996 01:47:41 -0500
*Sender*: owner-wri-mathgroup at wolfram.com
We can speed up Soluton 1 (attached) by a factor of 17 by using
NestList and matrix multiplication. The change to NestList accounts
for most of this: it accumulates the data needed for each frame when
computing the last one instead of starting from scratch every time.
The code is easily extended to 3D:
NEW CODE
A=(Table[{20,y},{y,20,80}]~Join~Table[{x,20},{x,20,80}])/101;
Image[A_] :=
Show[
Graphics[
{PointSize[.03],Text[i++,{.95,.95},{1,0}],Map[Point,A]}
],
AspectRatio->Automatic,PlotRange->{{0,1},{0,1}},Frame->True,
FrameTicks->None
];
M = {{1,1},{1,2}};
i=0;
Image/@NestList[Mod[#.M,1]&,A,25]
Timing on NeXT Turbo is 5.55 seconds
The timing for Solution 1 is 95.6 seconds
To see the computation calculated frame by frame (as happens with
Solution 1 then we can use the following variant to the last line
NestList[(Image[#];#)&[Mod[#.M,1]]&,Image[A];A,25]
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk
>>>>>>>>>>
Begin forwarded message:
>From: wilson figueroa <wfigueroa at mosquito.com>
>Subject: [mg5314] Arnold's Cat Map
>Organization: Mosquito Net, Inc.
Hi group,
I am attempting to implement Arnold's Cat Map using Mathematica
and have received two excellent solutions.
These are shown below.
-------------------------------------------------------------------
Soluton 1:
A=(Table[{20,y},{y,20,80}]~Join~Table[{x,20},{x,20,80}])/101;
T[{x_,y_}]:=Mod[{x+y,x+2*y},1]
MFold[A_,T_,i_]:=Fold[Map[T,#]&,A,Table[A,{i}]]
Image[A_,i_]:=\
Show[Graphics[{PointSize[1/30],Text[i,{.95,.95},{1,0}],Map[Point,A]}],
AspectRatio->1,PlotRange->{{0,1},{0,1}},Frame->True,FrameTicks->None]
Table[Image[MFold[A,T,i],i],{i,0,25}]
-------------------------------------------------------------------
Solution 2:
PointQ[p_] := VectorQ[p, NumberQ] && Length[p] == 2;
m = {{1,1}, {1,2}};
cat[x_?PointQ] := Mod[m.x, 1];
cat2[x_, 0] := x
cat[x_, 1] := cat[x]
cat2[x_, n_] := cat[cat2[x, n-1]]
cat2[{27/76, 58/76}, 9]
\!\({27\/76, 29\/38}\)
period[x_] := Module[{i=2},
While[Nest[cat,x, i]=!= x, i++];
i]
period[{3/101, 6/101}]
25
period[{27/76, 58/76}]
9
catgraph[r_, n_] := Module[{line, line2},
line = Table[{i, i}/r,{i, 0, r-1}];
line2 = Apply[Point[{#1, #2}]&, line, 1];
Show[Graphics[line2/.x_?PointQ :> cat2[x, n]],
Frame->True,
AspectRatio->Automatic
]
]
Table[catgraph[101,i],{i,0,25}]
---------------------------------------------------------------------
I would like one iteration more which allows me to implement this
solution using any color image. I would especially like to use a color
image of a cat. There is a great cat image in the new MMA v 3.0
manual.
Can someone proficient with handling images help here?
Also, does anyone know if the Arnold's Cat Map transformation is
applicable in n-dimensions, particurlarly in three dimensions as
this should be producable graphically using MMA v 3.0.
I would like to thank individuals who have provided the solutions
shown above. Both have very nice features and are very
efficient.
Thank you to anyone in the group who can provide help.
Sincerely,
Wilson Figueroa
wfiguero at mosquito.com
Prev by Date:
**Re: ComplexExpand**
Next by Date:
**mma and postscript**
Previous by thread:
**Arnold's Cat Map**
Next by thread:
**Re: Arnold's Cat Map**
| |