GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Romberg's method

In numerical analysis, Romberg's method is used to estimate the definite integral \int_a^b f(x) \, dx by applying Richardson extrapolation repeatedly on the trapezium rule or the rectangle rule (midpoint rule). The estimates generate a triangular array. Romberg's method is a Newton–Cotes formula – it evaluates the integrand at equally spaced points. The integrand must have continuous derivatives, though fairly good results may be obtained if only a few derivatives exist. If it is possible to evaluate the integrand at unequally spaced points, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are generally more accurate. The method is named after Werner Romberg... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

In numerical analysis, Romberg's method is used to estimate the definite integral \int_a^b f(x) \, dx by applying Richardson extrapolation repeatedly on the trapezium rule or the rectangle rule (midpoint rule). The estimates generate a triangular array. Romberg's method is a Newton–Cotes formula – it evaluates the integrand at equally spaced points. The integrand must have continuous derivatives, though fairly good results may be obtained if only a few derivatives exist. If it is possible to evaluate the integrand at unequally spaced points, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are generally more accurate. The method is named after Werner Romberg, who published the method in 1955. Using h_n = \frac{(b-a)}{2^{n+1}} , the method can be inductively defined by \begin{align} R(0,0) &= h_0 (f(a) + f(b)) \\ R(n,0) &= \tfrac{1}{2} R(n{-}1,\,0) + 2h_n \sum_{k=1}^{2^{n-1}} f(a + (2k-1)h_{n-1}) \\ R(n,m) &= R(n,\,m{-}1) + \tfrac{1}{4^m-1} (R(n,\,m{-}1) - R(n{-}1,\,m{-}1)) \\ &= \frac{1}{4^m-1} ( 4^m R(n,\,m{-}1) - R(n{-}1,\, m{-}1)) \end{align} where n \ge m and Observe that the first two equations correspond to the first column, and these are the formulas associated to the compound trapezoidal rule. In big O notation, the error for is: O{\left(h_n^{2m+2}\right)}. The zeroth extrapolation, , is equivalent to the trapezoidal rule with points; the first extrapolation, , is equivalent to Simpson's rule with points. The second extrapolation, , is equivalent to Boole's rule with points. The further extrapolations differ from Newton-Cotes formulas. In particular further Romberg extrapolations expand on Boole's rule in very slight ways, modifying weights into ratios similar as in Boole's rule. In contrast, further Newton-Cotes methods produce increasingly differing weights, eventually leading to large positive and negative weights. This is indicative of how large degree interpolating polynomial Newton-Cotes methods fail to converge for many integrals, while Romberg integration is more stable. By labelling our O(h^2) approximations as A_0\big(\frac{h}{2^n}\big) instead of R(n,0) , we can perform Richardson extrapolation with the error formula defined below: \int_a^b f(x) \, dx = A_0\bigg(\frac{h}{2^n}\bigg)+a_0\bigg(\frac{h}{2^n}\bigg)^{2} + a_1\bigg(\frac{h}{2^n}\bigg)^{4} + a_2\bigg(\frac{h}{2^n}\bigg)^{6} + \cdots Once we have obtained our O(h^{2(m+1)}) approximations A_m\big(\frac{h}{2^n}\big) , we can label them as R(n,m) . When function evaluations are expensive, it may be preferable to replace the polynomial interpolation of Richardson with the rational interpolation proposed by . include include void print_row(size_t i, double *R) { printf("R[%2zu] = ", i); for (size_t j = 0; j 1 && fabs(Rp[i-1]-Rc[i]) Here is an implementation of the Romberg method (in the Python programming language): import numpy as np from math import erf, sqrt, pi def print_row(row): # Print one row of the Romberg table in a fixed-width numeric format. # This makes the convergence pattern easy to read column by column. print(" ".join(f"{x:11.8f}" for x in row)) def romberg(f, a, b, eps=1e-8, max_iter=20): """ Approximate the definite integral of f from a to b using Romberg integration. Parameters ---------- f : callable Function to integrate. It should ideally accept NumPy arrays so that evaluations at many points can be vectorized. a, b : float Lower and upper limits of integration. eps : float, optional Desired stopping tolerance. The algorithm stops when two successive diagonal Romberg estimates are close enough. max_iter : int, optional Maximum number of refinement levels allowed. Returns ------- float The best Romberg estimate of the integral. """ # R[n, m] will hold the nth refinement and the mth Richardson extrapolation. R = np.zeros((max_iter+1, max_iter+1)) # Base case: trapezoidal rule using only the endpoints a and b. # This is the first and coarsest approximation to the integral. R[0, 0] = (b - a)*(f(a) + f(b))/2 # Print the first row, which contains only the initial trapezoidal estimate. print_row(R[0, :1]) # Refine the approximation level by level. # Each new level halves the step size and adds the function values at the # new midpoints introduced by subdivision. for n in range(1, max_iter+1): # Step size at refinement level n. # Since the interval is split into 2^n subintervals, the mesh width is: h_n1 = (b - a)/(2**n) # h_{n-1} # Generate the new points introduced at this refinement level. # These are the odd multiples of h relative to a: # a + h, a + 3h, a + 5h, ..., a + (2^n - 1)h # # There are 2^(n-1) such points, and NumPy generates them efficiently. x = a + h_n1*np.arange(1, 2**n, 2) # Update the trapezoidal estimate using the recursive Romberg relation:. R[n, 0] = R[n-1, 0]/2 + h_n1*np.sum(f(x)) # Richardson extrapolation: for m in range(1, n+1): R[n, m] = R[n, m-1] + (R[n, m-1] - R[n-1, m-1])/(4**m - 1) # Print the completed row up to the current diagonal element. print_row(R[n, :n+1]) # Stopping criterion: # If the last two diagonal-related values are sufficiently close, # we accept the most recent extrapolated estimate. if abs(R[n, n] - R[n, n-1]) ROMBINT – code for MATLAB (author: Martin Kacenak) Free online integration tool using Romberg, Fox–Romberg, Gauss–Legendre and other numerical methods SciPy implementation of Romberg's method Romberg.jl — Julia implementation (supporting arbitrary factorizations, not just 2^n+1 points)

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Romberg's method". 1783795281. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1363703178

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·