intergrate f(x) = exp^-2x * sinh x / sqrt(sin x - tan x) the limit is 0 to 10 using romberg
1 view (last 30 days)
Show older comments
i'm new in matlab. please help to intergrate f(x) = exp^-2x * sinh x / sqrt(sin x - tan x) the limit is 0 to 10 using romberg. i have tried to follows this steps but can't find the answer :
function intg = romberg(func, a, b, es, maxit) % romberg(func, a, b, es, maxit): %input: % func = name of function to be integrated % a, b = integration limits % es = (optional) stop criterion (%) ; defalut = 0.00001 % maxit = (optional) max allow iteratiosn; default = 30 % output: % int = integral estimate % if necessary, assign default values if nargin < 5, maxit = 30; end % if maxit blank set to 30 if nargin < 4, es=0.00001; end % if es blank set to 0.0001
n=1; I(1,1) = trap(func, a, b, n); iter = 0; while iter<maxit iter = iter +1; n=2^iter; I(iter+1,1)= trap(func, a, b, n); for k = 2:iter+1 j = 2+iter-k; I(j,k) = (4^(k-1)*I(j+1,k-1)-I(j,k-1))/(4^(k-1)-1); end ea = abs((I(1,iter+1)-I(2,iter))/I(1,iter+1))*100; if ea <= es, break; end end intg = I(1, iter+1);
0 Comments
Answers (0)
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!