早教吧作业答案频道 -->其他-->
用龙贝格法求积分被积函数为(2/sqrt(pi))*exp(-x)区间为(0,1),要求误差不超过。(计算取6位小数)
题目详情
用龙贝格法求积分被积函数为(2/sqrt(pi))*exp(-x)区间为(0,1) ,要求误差不超过 。(计算取6位小数)
▼优质解答
答案和解析
先用另外2种方法。 format long %【1】精确值。符号积分 it=int('(2/sqrt(pi))*exp(-x)',0,1) Accurate=eval(it) y=inline('(2/sqrt(pi))*exp(-x)') %【2】Simpson方法 Simpson=quad(y,0,1) delta=Simpson-Accurate 结果: Accurate = 0.713271669674918 y = Inline function: y(x) = (2/sqrt(pi))*exp(-x) Simpson = 0.713271671228492 delta = 1.553574158208448e-009 【3】从网上找到一个,存为romberg.m %================= function R = romberg(f, a, b, n) format long % ROMBERG -- Compute Romberg table integral approximation. % % SYNOPSIS: % R = romberg(f, a, b, n) % % DESCRIPTION: % Computes the complete Romberg table approximation to the integral % % / b % I = | f(x) dx % / a % % PARAMETERS: % f - The integrand. Assumed to be a function callable as % y = f(x) % with `x' in [a, b]. % a - Left integration interval endpoint. % b - Right integration interval endpoint. % n - Maximum level in Romberg table. % % RETURNS: % R - Romberg table. Represented as an (n+1)-by-(n+1) lower % triangular matrix of integral approximations. % % SEE ALSO: % TRAPZ, QUAD, QUADL. % NOTE: all indices adjusted for MATLAB's one-based indexing scheme. % Pre-allocate the Romberg table. Avoids subsequent re-allocation which % is often very costly. R = zeros([n + 1, n + 1]); % Initial approximation. Single interval trapezoidal rule. R(0+1, 0+1) = (b - a) / 2 * (feval(f, a) + feval(f, b)); % First column of Romberg table. Increasingly accurate trapezoidal % approximations. for i = 1 : n, h = (b - a) / 2^i; s = 0; for k = 1 : 2^(i-1), s = s + feval(f, a + (2*k - 1)*h); end R(i+1, 0+1) = R(i-1+1, 0+1)/2 + h*s; end % Richardson extrapolation gives remainder of Romberg table. % % Note: The table is computed by columns rather than the more % traditional row version. The reason is that this prevents frequent % (and needless) re-computation of the `fac' quantity. % % Moreover, MATLAB matrices internally use ``column major'' ordering so % this version is less harmful to computer memory cache systems. This % reason is an implementational detail, though, and less important in % introductory courses such as MA2501. for j = 1 : n, fac = 1 / (4^j - 1); for m = j : n, R(m+1, j+1) = R(m+1, j-1+1) + fac*(R(m+1, j-1+1) - R(m-1+1, j-1+1)); end end function ff=f(x) ff=2/sqrt(pi)*exp(-x); %================= 运行: >> R=romberg('f', 0, 1, 5) R = 0.771743332258054 0 0 0 0 0 0.728069946441243 0.713512151168973 0 0 0 0 0.716982762290904 0.713287034240791 0.713272026445579 0 0 0 0.714200167058928 0.713272635314936 0.713271675386546 0.713271669814180 0 0 0.713503839348432 0.713271730111600 0.713271669764711 0.713271669675476 0.713271669674932 0 0.713329714927254 0.713271673453528 0.713271669676323 0.713271669674920 0.713271669674918 0.713271669674918
看了 用龙贝格法求积分被积函数为(...的网友还看了以下:
关于微分的应用题1、底面半径为14cm的圆锥的高从7cm变为7.1cm时,求此圆锥体积该变量的近似值 2020-03-30 …
英语翻译特殊货物装卸需大型机力,成本另行单独报价.目前参考收费如下:1、单件货物体积超过1.2m* 2020-05-20 …
产权登记面积和合同约定面积的问题!请问:我买了一套房合同约定面积是100.06㎡,但是交房时产权登 2020-05-23 …
概率论正态分布问题一个零件的长度误差X是随机变量,已知X-N(3,4),(1)误差不超过3的概率? 2020-06-10 …
1灯内酒精的量不能少于容积的_,最多不能超过容积的_;2不进行加热,试管内液体不能超过容积的_;3 2020-07-02 …
关于各国土地资源现状描述错误的是()A.ri本地狭人稠,人均耕地面积极少B.印度国土面积不足中国的 2020-07-16 …
两个含有同一个字母的二项式相乘,下列说法中,错误的是()A.积可能是四项式B.积可能是二项式或三项 2020-07-22 …
要使圆面积的相对误差限不超过0.02,则半径的相对误差限不超过多少? 2020-08-02 …
一道随机变量问题一个零件的长度误差X是随机变量,已知X-N(3,4),(1)误差不超过3的概率?( 2020-08-02 …
2005年上海人均公共绿地面积要比2004年增加近1平方米,达到11平方米,绿化整体覆盖率超过37% 2020-12-29 …