# Feigenbaum constant calculation

Feigenbaum constant calculation is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Calculate the Feigenbaum constant. See details: Feigenbaum constant

## Kotlin

Translation of: Ring

<lang scala>// Version 1.2.40

fun feigenbaum() {

```   val maxIt = 13
val maxItJ = 10
var a1 = 1.0
var a2 = 0.0
var d1 = 3.2
println(" i       d")
for (i in 2..maxIt) {
var a = a1 + (a1 - a2) / d1
for (j in 1..maxItJ) {
var x = 0.0
var y = 0.0
for (k in 1..(1 shl i)) {
y = 1.0 - 2.0 * y * x
x = a - x * x
}
a -= x / y
}
val d = (a1 - a2) / (a - a1)
println("%2d    %.8f".format(i,d))
d1 = d
a2 = a1
a1 = a
}
```

}

fun main(args: Array<String>) {

```   feigenbaum()
```

}</lang>

Output:
``` i       d
2    3.21851142
3    4.38567760
4    4.60094928
5    4.65513050
6    4.66611195
7    4.66854858
8    4.66906066
9    4.66917155
10    4.66919515
11    4.66920026
12    4.66920098
13    4.66920537
```

## Ring

<lang ring>

1. Project : Feigenbaum constant calculation
2. Date  : 2018/04/20
3. Author : Gal Zsolt [~ CalmoSoft ~]
4. Email  : <calmosoft@gmail.com>

decimals(8) see "Feigenbaum constant calculation:" + nl maxIt = 13 maxItJ = 10 a1 = 1.0 a2 = 0.0 d1 = 3.2 see "i " + "d" + nl for i = 2 to maxIt

```    a = a1 + (a1 - a2) / d1
for j = 1 to maxItJ
x = 0
y = 0
for k = 1 to pow(2,i)
y = 1 - 2 * y * x
x = a - x * x
next
a = a - x / y
next
d = (a1 - a2) / (a - a1)
if i < 10
see "" + i + "    " + d + nl
else
see "" + i + "  " + d + nl
ok
d1 = d
a2 = a1
a1 = a
```

next </lang> Output:

```Feigenbaum constant calculation:
i  d
2  3.21851142
3  4.38567760
4  4.60094928
5  4.65513050
6  4.66611195
7  4.66854858
8  4.66906066
9  4.66917155
10 4.66919515
11 4.66920026
12 4.66920098
13 4.66920537
```