Task

Calculate the Feigenbaum constant.



See

   Details in the Wikipedia article:   Feigenbaum constant.


' version 25-0-2019
' compile with: fbc -s console
 
Dim As UInteger i, j, k, maxit = 13, maxitj = 13
Dim As Double x, y, a, a1 = 1, a2, d, d1 = 3.2
 
Print "Feigenbaum constant calculation:"
Print
Print "  i     d"
Print "==================="
 
For i = 2 To maxIt
    a = a1 + (a1 - a2) / d1
    For j = 1 To maxItJ
        x = 0 : y = 0
        For k = 1 To 2 ^ i
            y = 1 - 2 * y * x
            x = a - x * x
        Next
        a = a - x / y
    Next
    d = (a1 - a2) / (a - a1)
    Print Using "###    ##.#########"; i; d
    d1 = d
    a2 = a1
    a1 = a
Next
 
' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End