Skip to content

Instantly share code, notes, and snippets.

@butchi
Last active December 20, 2015 13:33
Show Gist options
  • Save butchi/59d81c2af9beee1f2b33 to your computer and use it in GitHub Desktop.
Save butchi/59d81c2af9beee1f2b33 to your computer and use it in GitHub Desktop.
フィボナッチ列フラクタル(Mathematicaショートフラクタルシリーズ) ref: http://qiita.com/butchi_y/items/fe0fa7d3e7909ec00210
w = Flatten[Nest[{#, #[[1]]} &, {1, 0}, 20]];
ListPlot[{Re[#], Im[#]} & /@
Accumulate[
Join[
{0},
I^Accumulate[Join[{1}, w*(-1)^Mod[Range[Length[w]], 2]]]
]
],
Joined -> True,
AspectRatio -> Automatic
]
Graphics[Line[{Re[#],Im[#]}&/@FoldList[Plus,0,I^FoldList[Plus,1,Flatten[Nest[{#,#[[1]]}&,{1,0},20]]*(-1)^Range[28657]]]]]
In[1] := w = Flatten[Nest[{#, #[[1]]} &, {1, 0}, 5]];
Out[1] := {1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1}
In[2] := Accumulate[Join[{1}, w*(-1)^Mod[Range[Length[w]], 2]]]
Out[2] := {1, 0, 0, -1, 0, 0, 1, 1, 2, 1, 1, 0, 1, 1, 2, 2, 3, 2, 2, 1, 1, 0}
In[3] := I^Accumulate[Join[{1}, w*(-1)^Mod[Range[Length[w]], 2]]]
Out[3] := {I, 1, 1, -I, 1, 1, I, I, -1, I, I, 1, I, I, -1, -1, -I, -1, -1, I, I,
1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment