Feigenbaum constant calculation: Difference between revisions

m
 
(8 intermediate revisions by 6 users not shown)
Line 244:
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">100 cls
110 mit = 13
120 mitj = 13
130 a1 = 1
140 a2 = 0
150 d = 0
160 d1 = 3.2
170 print "Feigenbaum constant calculation:"
180 print
190 print " i d"
200 print "==================="
210 for i = 2 to mit
220 a = a1+(a1-a2)/d1
230 for j = 1 to mitj
240 x = 0
250 y = 0
260 for k = 1 to 2^i
270 y = 1-2*y*x
280 x = a-x*x
290 next k
300 a = a-(x/y)
310 next j
320 d = (a1-a2)/(a-a1)
330 print using "###";i;" ";
335 print using "##.#########";d
340 d1 = d
350 a2 = a1
360 a1 = a
370 next i
380 end</syntaxhighlight>
 
==={{header|Just BASIC}}===
Line 270 ⟶ 304:
a1 = a
next i</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">100 CLS
110 mit = 13
120 mitj = 13
130 a1 = 1
140 a2 = 0
150 d = 0
160 d1 = 3.2
170 PRINT "Feigenbaum constant calculation:"
180 PRINT
190 PRINT " i d"
200 PRINT "==================="
210 FOR i = 2 TO mit
220 a = a1 + (a1 - a2) / d1
230 FOR j = 1 TO mitj
240 x = 0
250 y = 0
260 FOR k = 1 TO 2 ^ i
270 y = 1 - 2 * y * x
280 x = a - x * x
290 NEXT k
300 a = a - (x / y)
310 NEXT j
320 d = (a1 - a2) / (a - a1)
330 PRINT USING "### ##.#########"; i; d
340 d1 = d
350 a2 = a1
360 a1 = a
370 NEXT i
380 END</syntaxhighlight>
 
==={{header|True BASIC}}===
Line 514 ⟶ 581:
12 4.66920099
13 4.66920555</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
Translated from Algol
<syntaxhighlight lang="Delphi">
 
 
procedure FeigenbaumConstant(Memo: TMemo);
{ Calculate the Feigenbaum constant }
const IMax = 13;
const JMax = 10;
var I,J,K: integer;
var A1,A2,D1,X,Y: double;
var A,D: double;
begin
Memo.Lines.Add('Feigenbaum constant calculation:');
{Set initial starting values for iterations}
A1:=1.0; A2:=0.0; D1:=3.2;
Memo.Lines.Add(' I A D');
for I:=2 to IMax do
begin
{Find next Bifurcation parameter, A}
A:=A1 + (A1 - A2) / D1;
for J:=1 to JMax do
begin
X:=0; Y:=0;
for K:=1 to 1 shl i do
begin
Y:=1 - 2 * y * x;
X:=A - X * X
end;
A:=A - X / Y
end;
{Use current and previous values of A}
{to calculate the Feigenbaum constant D }
D:= (A1 - A2) / (A - A1);
Memo.Lines.Add(Format('%2d %2.8f %2.8f',[I,A,D]));
D1:=D; A2:=A1; A1:=A;
end;
end;
 
</syntaxhighlight>
{{out}}
<pre>
Feigenbaum constant calculation:
I A D
2 1.31070264 3.21851142
3 1.38154748 4.38567760
4 1.39694536 4.60094928
5 1.40025308 4.65513050
6 1.40096196 4.66611195
7 1.40111380 4.66854858
8 1.40114633 4.66906066
9 1.40115329 4.66917155
10 1.40115478 4.66919515
11 1.40115510 4.66920028
12 1.40115517 4.66920099
13 1.40115519 4.66920555
</pre>
 
=={{header|EasyLang}}==
{{trans|AWK}}
<syntaxhighlight>
numfmt 6 0
a1 = 1 ; a2 = 0 ; d1 = 3.2
ipow2 = 4
for i = 2 to 13
a = a1 + (a1 - a2) / d1
for j = 1 to 10
x = 0 ; y = 0
for k = 1 to ipow2
y = 1 - 2 * y * x
x = a - x * x
.
a -= x / y
.
d = (a1 - a2) / (a - a1)
print i & " " & d
d1 = d ; a2 = a1 ; a1 = a
ipow2 *= 2
.
</syntaxhighlight>
 
=={{header|F#|F sharp}}==
Line 708 ⟶ 858:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Feigenbaum_constant_calculation}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
 
[[File:Fōrmulæ - Feigenbaum constant calculation 01.png]]
 
'''Test case'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Feigenbaum constant calculation 02.png]]
In '''[https://formulae.org/?example=Feigenbaum_constant_calculation this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Feigenbaum constant calculation 03.png]]
 
=={{header|FutureBasic}}==
Line 1,251 ⟶ 1,406:
for j = 1 to maxitj {x=0:y=0:for k=1 to 2&^i {y=1@-2@*y*x:x=a-x*x}:a-=x/y}
d=(a1-a2)/(a-a1)
print format$("{0::-7} {1:10:-12} {2::-5}",i, d, int(maxitj)j-1)
maxitj-=c
d1=d:a2=a1:a1= a
Line 1,265 ⟶ 1,420:
2 3.2185114220 13
3 4.3856775986 12
4 4.6009492765 1112
5 4.6551304954 1011
6 4.6661119478 10
7 4.6685485814 910
8 4.6690606606 89
9 4.6691715554 8
10 4.6691951560 7
11 4.6692002291 67
12 4.6692013133 6
13 4.6692015458 5
14 4.6692015955 45
15 4.6692016062 34
16 4.6692016085 3
17 4.6692016090 23
18 4.6692016091 2
</pre>
Line 2,081 ⟶ 2,236:
{{trans|Ring}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var feigenbaum = Fn.new {
2,063

edits