4.10 Romberg Integration
Using Richardson Extrapolation (a deffered approach to the limit)
h1=(b−a),h2=(b−a)2,⋯,hn=(b−a)2n−1
I1=(b−a)2(f(a)+f(b))In+1=In2+hn+12n−1∑i=1f(a+(2i−1)hn+1)Ri,1=IiRi,j=Ri,j−1+Ri,j−1−Ri−1,j−14j−1−1
Rn,n is the answer!
Practice script
romb
## function (fx, a, b, N = 4)
## {
## R = matrix(nrow = N, ncol = N)
## h = b - a
## R[1, 1] = h/2 * (fx(a) + fx(b))
## np = 1
## for (i in 2:N) {
## h = h/2
## np = 2 * np
## R[i, 1] = 1/2 * R[i - 1, 1] + h * sum(fx(a + h * seq(1,
## np - 1, 2)))
## for (j in 2:i) {
## R[i, j] = R[i, j - 1] + (R[i, j - 1] - R[i - 1, j -
## 1])/(4^(j - 1) - 1)
## }
## }
## return(R[N, N])
## }
## <bytecode: 0x000001e2a3f4fd98>
## <environment: namespace:math>
= function(x) exp(-x/100)
fx format(romb(fx, 0, 24), digits=22)
## [1] "21.33721389334470330823"
= function(x) 3 * x * sin(x) - log(x)
fx2 format(romb(fx2, 0.8, 2.6), digits=22)
## [1] "6.887425952851619292971"
format(romb(fx2, 0.8, 2.6, N=8), digits=22)
## [1] "6.887419623354108288993"