Post Reply 
HP71B Integral Questions
02-03-2020, 04:15 PM (This post was last modified: 04-14-2021 12:52 AM by Albert Chan.)
Post: #4
RE: HP71B Integral Questions
(02-03-2020 03:00 PM)J-F Garnier Wrote:  Is the 8-level Romberg scheme close to the Richardson Extrapolations you used?

Romberg's methodRichardson Extrapolations applied to Trapezoids area.

I did the u-transformed trapezoids area in Lua, then copy/paste to Excel

Code:
function u(f, a, b)       -- u-transformed f
    local c, d = (b-a)/4, (b+a)/2
    local k = 3*c
    return function(u)      -- u = (-1, 1)
        local w = (1+u)*(1-u)
        return w==0 and 0 or k*w*f(c*u*(w+2)+d)
    end
end

function trapezoid(f, a, b, t0)
    local n = 2
    local h = (b-a)*0.5
    t0 = t0 or (f(a) + f(b)) * h
    local function iter()
        while true do
            local s = 0
            for i = 1, n, 2 do s = s + f(a + i*h) end
            local t1 = t0*0.5 + s*h
            coroutine.yield(t1)
            t0, n, h = t1, n*2, h*0.5
        end
    end
    return coroutine.wrap(iter)
end

lua> a, b, c = 6.371e6, 9.4607304725808e15, 3.98589196e17
lua> exp, log = math.exp, math.log
lua> function fna(x) return c/exp(x) end
lua> t = trapezoid(u(fna, log(a), log(b)), -1, 1)
lua> for i=1,7 do print(2^i, t()) end
2      25715027.086919405
4      13721555535.80971
8      50890703123.90066
16     59914609212.0083
32     61913859849.80031
64     62401515156.47649
128    62522713769.32443

Only 2 formulas used in Excel, one for the weight, second for the extrapolation. Others are just copies.
With this setup, Simpson's rule have weight of 3, Boole's rule have weight of 15, ...
Code:
   A   B                   C
1|                         =4*B1+3
2| 1   0       
3| 2   25715027.0869194    =B3+(B3-B2)/C$1
4| 4   13721555535.8097    =B4+(B4-B3)/C$1
5| 8   50890703123.9006    =B5+(B5-B4)/C$1
6| 16  59914609212.0083    =B6+(B6-B5)/C$1
7| 32  61913859849.8003    =B7+(B7-B6)/C$1
8| 64  62401515156.4764    =B8+(B8-B7)/C$1
9| 128 62522713769.3244    =B9+(B9-B8)/C$1
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP71B Integral Questions - Albert Chan - 02-02-2020, 03:31 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020, 01:58 PM
RE: HP71B Integral Questions - J-F Garnier - 02-03-2020, 03:00 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020 04:15 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020, 11:15 PM
RE: HP71B Integral Questions - J-F Garnier - 02-05-2020, 08:43 AM
RE: HP71B Integral Questions - Albert Chan - 02-05-2020, 05:09 PM
RE: HP71B Integral Questions - Wes Loewer - 02-06-2020, 06:53 PM
RE: HP71B Integral Questions - Albert Chan - 02-06-2020, 11:16 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 03:49 AM
RE: HP71B Integral Questions - Albert Chan - 02-07-2020, 08:14 AM
RE: HP71B Integral Questions - J-F Garnier - 02-07-2020, 08:23 AM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 01:19 PM
RE: HP71B Integral Questions - Albert Chan - 02-07-2020, 05:08 PM
RE: HP71B Integral Questions - J-F Garnier - 02-07-2020, 05:54 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 08:16 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 08:12 PM
RE: HP71B Integral Questions - J-F Garnier - 02-05-2020, 06:20 PM
RE: HP71B Integral Questions - Albert Chan - 02-05-2020, 07:52 PM
RE: HP71B Integral Questions - J-F Garnier - 02-06-2020, 08:37 AM
RE: HP71B Integral Questions - Wes Loewer - 02-08-2020, 10:46 AM
RE: HP71B Integral Questions - J-F Garnier - 02-08-2020, 10:59 AM
RE: HP71B Integral Questions - Wes Loewer - 02-08-2020, 03:04 PM
RE: HP71B Integral Questions - Albert Chan - 02-09-2020, 01:43 PM
RE: HP71B Integral Questions - Wes Loewer - 02-09-2020, 08:33 PM
RE: HP71B Integral Questions - Albert Chan - 02-10-2020, 01:33 PM
RE: HP71B Integral Questions - Wes Loewer - 02-09-2020, 09:03 PM
RE: HP71B Integral Questions - Albert Chan - 02-11-2020, 05:03 PM
RE: HP71B Integral Questions - Albert Chan - 02-11-2020, 11:57 PM
RE: HP71B Integral Questions - Albert Chan - 02-21-2020, 11:23 PM



User(s) browsing this thread: 5 Guest(s)