TransWikia.com

How to construct rectangular figures from the Fibonacci numbers?

Mathematica Asked by user60670 on July 2, 2021

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

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

figure

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

figure

Answered by ZaMoC on July 2, 2021

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

rectangles


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

golden spiral

Answered by J. M.'s torpor on July 2, 2021

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

enter image description here

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

Answered by chyanog on July 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP