How do you construct rectangular figures ("golden rectangles") using the Fibonacci numbers in Mathematica using graphics? I know that the basis of the construction of these figures are the formulae for summing the terms, the odd-indexed terms, the even-indexed terms and the sum of the squares of the terms. I'm really confused on how to obtain the rectangular figures.
3 Answers
$\begingroup$
$\endgroup$
0 NestList[] is very handy for situations like this:
tr[Polygon[p_]] := Polygon[Composition[TranslationTransform[First[p]], AffineTransform[{{0, -1}, {1, 0}}/GoldenRatio], TranslationTransform[-Last[p]]] @ p] g1 = Graphics[{EdgeForm[Black], MapIndexed[{ColorData[61] @@ #2, #1} &, NestList[tr, Polygon[{{GoldenRatio, 0}, {GoldenRatio, 1}, {0, 1}, {0, 0}} // N], 10]]}] 
If you want to see the accompanying golden spiral as well:
tr[Circle[c_, r_, ang_]] := Circle[c + r AngleVector[Last[ang]]/(1 + GoldenRatio), r/GoldenRatio, ang + π/2] Show[g1, Graphics[{Directive[Pink, AbsoluteThickness[2]], NestList[tr, Circle[{1, 1}, 1, {π, 3 π/2}], 10]}]] 
$\begingroup$ $\endgroup$
1 you mean something like this?
Graphics[{Red, Rectangle[{0, 0}, {Fibonacci@6, Fibonacci@5}], Green, Rectangle[{0, 0}, {Fibonacci@4, Fibonacci@5}], Yellow, Rectangle[{0, 0}, {Fibonacci@4, Fibonacci@3}], Blue, Rectangle[{0, 0}, {Fibonacci@2, Fibonacci@3}], Pink, Rectangle[{0, 0}, {Fibonacci@2, Fibonacci@1}]}] but if you want the real thing, here you are..
gr[0] := {{0, 0}, {1, -1}}; gr[n_] := Module[{φ = GoldenRatio, m = Mod[n, 4], a, b, c, d}, {{a, b}, {c, d}} = gr[n - 1]; Switch[Mod[n, 4], 0, {{a, d}, {a + φ^-n, d - φ^-n}}, 1, {{c, d + φ^-n}, {c + φ^-n, d}}, 2, {{c - φ^-n, b + φ^-n}, {c, b}}, 3, {{a - φ^-n, b}, {a, b - φ^-n}}]]; Graphics[{EdgeForm[Opacity[.5]],Table[{ColorData[24, k + 1], Rectangle @@gr[k]}, {k, 0, 10}]}] - 3$\begingroup$ Please don't use JPG for non-photographic images! :) If you look at the edges of your squares, especially at the bottoms of your images, you see strange stripes. This is caused by using JPG (a compressed format designed to be used with photographs) for something that very much isn't a photograph! PNG is the preferred format for illustrations, screenshots, diagrams, etc. (basically any image that isn't a photograph, especially if it contains large, solid-colour regions, text, or discrete curves). $\endgroup$Andreas Rejbrand– Andreas Rejbrand2018-10-12 05:41:51 +00:00Commented Oct 12, 2018 at 5:41
$\begingroup$ $\endgroup$
1 Inspired by Golden spiral in TiKZ: how do I get the right shape and background
My another post
Manipulate[ With[{tf = AffineTransform[{RotationMatrix[-2 θ]/GoldenRatio, {1, 1}}], n = Floor[x]}, With[{L = NestList[tf, N@{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 10]}, Graphics[{ {Opacity[0.5], Hue[x/10], Polygon[(1 - (x - n)) L[[n]] + (x - n) L[[n + 1]]], MapIndexed[{EdgeForm[Black], Hue[#2/10], #} &, Polygon /@ Take[L, n]]}, Red, NestList[GeometricTransformation[#, tf] &, Circle[(Cot[θ] {1, -1} + 1)/2, Csc[θ]/√2, {-θ, θ} + 3 π/4], n - 1] }, PlotRange -> {{-0.1, 3}, {-0.1, 3}}, ImageSize -> Large ]]], {{x, 5}, 1, 9}, {θ, .001, π/4}] Using complex numbers
Manipulate[ With[{n = Floor[x]}, {f = ReIm@NestList[# E^(-I 2 θ)/GoldenRatio + (1 + I) &, #, n] &}, {L = f[{0, 1, 1 + I, I, 0}]}, Graphics[{Line@L[[;; n]], Line[{1 - (x - n), x - n}.L[[-2 ;;]]], ParametricPlot[Most@f[(1 - I) (I + Cot[θ])/2 + E^(I α)Csc[θ]/Sqrt[2]], {α, -θ + 3 π/4, θ + 3 π/4}][[1]]}, PlotRange -> {{-0.1, 3}, {-0.1, 3}} ]], {{x, 5}, 1, 9}, {θ, .001, Pi/4}] - $\begingroup$ This's a great answer. $\endgroup$A little mouse on the pampas– A little mouse on the pampas2020-08-25 00:25:45 +00:00Commented Aug 25, 2020 at 0:25


