Palindromic Expression for Phi

From APL Wiki
Revision as of 11:40, 29 October 2021 by Adám Brudzewsky (talk | contribs) (Created page with "Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive dfn to compute the limit of a converging function, equiv...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive dfn to compute the limit of a converging function, equivalent to the derived monadic operator ⍣≡:[1]

limit←{             ⍝ Function power limit (fixpoint).
    ⍵ ⍺⍺{           ⍝ 'old' value:
        ⍺≡⍵:⍵       ⍝       old matches new: finished.
        ⍵ ∇ ⍺⍺ ⍵    ⍝       otherwise: try new value.
    }⍺⍺ ⍵           ⍝ 'new' value.
}

John Scholes noted that it was close to being a palindrome, so he inlined it and he amended it with dummy code to make its invocation for finding the golden ratio even closer to palindromic:

      1{1+÷⍵}{⍵ ⍺⍺{⍺≡⍵:⍵ ⋄ ⍵ ⍺⍺ ∇∇ ⍺⍺ ⍵ ⋄ ⍵:⍵≡⍺}⍺⍺ ⍵}{⍵÷+1}1
1.618033989

Scholes then published a minute-long video with musical accompaniment where he types the expression in a symmetric fashion, culminating with the execution.[2]

References

  1. Dyalog. Function power limit (fixpoint). Dfns workspace. 2019-02-07.
  2. DFunctionista. Palindromic Expression for Phi in APL. YouTube. 2009-02-13.