Skip to content
DeepForgeby svx
All problems
HardCalculusca-300

Romberg Table Two Levels

Problem

Build the first two levels of a Romberg table for the integral of a polynomial on [a, b]: T(h) is the trapezoidal estimate with spacing b - a, and T(h/2) uses two subintervals. Richardson extrapolation gives R = (4 * T(h/2) - T(h)) / 3.

Return the nested list [[T(h)], [T(h/2), R]].

Hint

Halve the spacing, then combine the two trapezoid estimates with 4/3 and 1/3.

Test cases

case 1
in: [[0,0,1],0,1]
expected: [[0.5],[0.375,0.3333333333333333]]
case 2
in: [[0,0,0,1],0,2]
expected: [[8],[5,4]]
case 3
in: [[1,0,0,1],0,1]
expected: [[1.5],[1.3125,1.25]]
Starter codePython
def romberg_table_two_levels(coeffs, a, b):
    # Your code here
    pass

3 test cases · run your code against them in the editor