On Thu, Feb 13, 2025 at 9:49 PM Lindsay Lawrence <
lawrence.lindsayj...@gmail.com> wrote:


> A bit of searching came up with the paper with the haskell version
>
> https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf
>
> Interestingly enough there is another version of PI in there, recursive,
> based on the Gosper series,
> that a faster... although it is based on a conjecture they haven't proven
> in that paper.
>
> The picolisp version of that one is below ('tco' is a nice fit for it as
> well!)
>

There was an error in the variable scoping of the function I posted in
previous email. Here is the corrected version

(de makePi (N)
  (let (G 1 R 180 S 60 I 2)
   (tco (G R S I N)
      (let
         (U (* 3 (+ (* 3 I) 1) (+ (* 3 I) 2) )
          Y (/ (+ (* G (- (* 27 I) 12)) (* 5 R) ) (* 5 S) ) )
         (prin Y)
         (if (or (not N) (gt0 N))
            (tc
               (* 10 G I (- (* 2 I) 1))
               (* 10 U (- (+ (* G (- (* 5 I) 2)) R) (* Y S) ) )
               (* S U)
               (+ I 1)
               (dec N) ) ) ) ) ))

/Lindsay

Reply via email to