Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1,46 @@
|
|||
# Helper function: compute (x, y)
|
||||
create or replace function xy(i, a) as table (
|
||||
with recursive cte1(k,y,x) as (
|
||||
select 0 as k, 0.0::DOUBLE as y, 0.0::DOUBLE as x -- 0 or 1
|
||||
union all
|
||||
select k+1 as k, (1.0 - 2.0 * x * y) as y, (a - (x * x) ) as x
|
||||
from cte1
|
||||
where k < power(2, i)
|
||||
)
|
||||
select last(x order by k) as x, last(y order by k) as y from cte1
|
||||
);
|
||||
|
||||
create or replace function compute_a(a0, i, jmax) as (
|
||||
with recursive cte2(j, a) as (
|
||||
select 0 as j, a0::DOUBLE as a
|
||||
union all
|
||||
(with xy as (from xy(i, a) )
|
||||
select 1+j as j, (a - (x / y) ) as a
|
||||
from cte2, xy
|
||||
where j <= jmax
|
||||
)
|
||||
)
|
||||
select last(a order by j) as a
|
||||
from cte2
|
||||
);
|
||||
|
||||
create or replace function feigenbaum_delta(imax, jmax) as table (
|
||||
with recursive cte(i, d, a1, a2) as (
|
||||
select 1 as i, 3.2::DOUBLE as d, 1.0::DOUBLE as a1, 0.0::DOUBLE as a2
|
||||
union all
|
||||
( with atable as (select compute_a((a1 + (a1 - a2) / d), i+1, jmax) as a from cte )
|
||||
select i+1 as i,
|
||||
(a1 - a2) / (atable.a - a1) as d,
|
||||
atable.a as a1,
|
||||
a1 as a2
|
||||
from cte, atable
|
||||
where i < imax
|
||||
)
|
||||
)
|
||||
select i, d as "δ"
|
||||
from cte
|
||||
order by i
|
||||
);
|
||||
|
||||
.print Feigenbaum's delta constant incremental calculation:
|
||||
from feigenbaum_delta(13, 10);
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
local function feigenbaum()
|
||||
local max_it = 13
|
||||
local max_it2 = 10
|
||||
local a1 = 1
|
||||
local a2 = 0
|
||||
local d1 = 3.2
|
||||
print(" i d")
|
||||
for i = 2, max_it do
|
||||
local a = a1 + (a1 - a2) / d1
|
||||
for _ = 1, max_it2 do
|
||||
local x = 0
|
||||
local y = 0
|
||||
for __ = 1, 1 << i do
|
||||
y = 1 - 2 * y * x
|
||||
x = a - x * x
|
||||
end
|
||||
a -= x / y
|
||||
end
|
||||
local d = (a1 - a2) / (a - a1)
|
||||
fmt.print("%2d %0.8f", i, d)
|
||||
d1 = d
|
||||
a2 = a1
|
||||
a1 = a
|
||||
end
|
||||
end
|
||||
|
||||
feigenbaum()
|
||||
|
|
@ -1,8 +1,15 @@
|
|||
-- 8 May 2025
|
||||
-- 28 Jul 2025
|
||||
include Settings
|
||||
arg n
|
||||
if n = '' then
|
||||
n = 30
|
||||
numeric digits n
|
||||
|
||||
say 'FIRST FEIGENBAUM CONSTANT'
|
||||
say version
|
||||
say
|
||||
say 'Using algorithm cf RosettaCode, correct to about 11 decimals'
|
||||
say
|
||||
arg n; if n = '' then n = 30; numeric digits n
|
||||
call Time('r'); a = Original(); e = Format(Time('e'),,3)
|
||||
say 'Original ' a '('e 'seconds)'
|
||||
call Time('r'); a = Optimized(); e = Format(Time('e'),,3)
|
||||
|
|
@ -12,8 +19,8 @@ say 'True value' a '('e 'seconds)'
|
|||
exit
|
||||
|
||||
Original:
|
||||
procedure expose glob.
|
||||
/* Outer 2 loops with a fixed value */
|
||||
procedure expose Memo.
|
||||
-- Outer 2 loops with a fixed value
|
||||
numeric digits Digits()+2
|
||||
im = 20; jm = 10
|
||||
a1 = 1; a2 = 0; d1 = 3.2
|
||||
|
|
@ -33,10 +40,10 @@ numeric digits Digits()-2
|
|||
return d+0
|
||||
|
||||
Optimized:
|
||||
procedure expose glob.
|
||||
/* Center loop stops on achieving desired accuracy */
|
||||
procedure expose Memo.
|
||||
-- Center loop stops on achieving desired accuracy
|
||||
numeric digits Digits()+4; numeric fuzz 4
|
||||
/* Only outer loop maximum */
|
||||
-- Only outer loop maximum
|
||||
im = 20
|
||||
a1 = 1; a2 = 0; d1 = 3.2
|
||||
do i = 2 to im
|
||||
|
|
@ -47,7 +54,7 @@ do i = 2 to im
|
|||
y = 1 - 2*x*y; x = a - x*x
|
||||
end
|
||||
a = a - x/y
|
||||
/* Stop second loop when a does not change anymore */
|
||||
-- Stop second loop when a does not change anymore
|
||||
if a = v then
|
||||
leave
|
||||
v = a
|
||||
|
|
@ -60,5 +67,7 @@ numeric digits Digits()-4
|
|||
return d+0
|
||||
|
||||
TrueValue:
|
||||
procedure expose glob.
|
||||
procedure expose Memo.
|
||||
return 4.66920160910299067185320382046620161725818557747576863274565134300413433021131473713868974402394801381716+0
|
||||
|
||||
include Abend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue