龙贝格算法主要是不断递推和加速,直到满足精度要求 递推: 加速: 得到T表: MATLAB代码: function I = Romberg(f, a, b, epsilon) I = 0; h = b-a; k = 0; m = 0; T = zeros(5); %下标转换:T^(k)_0 => T(k+1,1) T(1,1) = h/2 * (subs(f,a) + subs(f,b));%即T^(0)_0 delta = 2*epsilon; while delta > epsilon k
用龙贝格算法计算积分 #include <iostream> #include<cmath> #include <iomanip> using namespace std; int power(int a, int b) { int result = 1; if (b == 0) return result; while (b != 0) { result *= a; b--; } return result; } int main() { int M = 5;