Question

# Matlab function Simpson given below implements Simpson's 1/3 Rule to estimate

Image transcription text

Problem 5. Matlab function Simpson given below implements Simpson's 1/3 Rule to estimate I = So f(x)dx using n odd points. function I = Simpson (fun, a, b, n) % simpson Composite Simpson's rule %% % Synopsis: I = simpson (fun, a, b, npanel) % Input : fun = (string) name of the function that evaluates f (x) % a, b = lower and upper limits of the integral n = number of nodes, odd and &gt; 2. % Output : I = approximate value of the integral from a to b of f(x)*dx if (mod (n, 2) == 0) || (n &lt; 3) disp(' Warning: n must be &gt; 1 and odd, program terminates . .. ') ; return; end dx = (b-a) / (n-1) ; % stepsize x = a: dx: b; divide the interval f = feval (fun, x) ; % evaluate integrand I = (dx/3) *(f(1) + 4*sum(f (2:2:n-1) ) + 2*sum(f (3:2:n-2) ) + f(n)); Now, it is desired to estimate the definite integral I 1 = 37 sin(x/3) da 2 - cos(2/2) (6) correct to at least 4 significant digits, by the use of Simpson's 1/3 rule. For this purpose start with n = 3 and increase n by 2 at a time until your result meets the required accuracy. Use Matlab function Simpson given above for the solution of this problem. Compare your answer with Matlab's quad () function. Comment on your computation.

...

Solved by verified expert

llentesque dapibus efficitur laoreet. Nam risus ante, dapi

entesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac,

l

sus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum

Explore over 16 million step-by-step answers from our library

Step-by-step explanation

congue vel

pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus a

m ipsum dolor sit amet, consect

icitur laoreet. Nam risu

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel

itur laoreet. N

at,

llentesque dapi

onec aliq

m risus ante, d

icitur laoreet. Nam risus ante, dapibus a molestie conse

at,

ce dui lectus, congue vel laoreet ac, dictum vitae odio.

s a molest

fficitur laoreet. Nam risus ante,

sus ante, d

ce dui lectus, co

ongue ve

at, ultrices ac magna. Fus

m ipsum dolor sit ame

, consectetu

entesq

at,

, dictum vitae odio. Donec aliquet. Lorem ipsum

ur laoreet. Nam risus ante, dapibus a molestie consequat,

or nec facilisis. Pellentesque dap

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dol

s a m

tesque dapibus efficiturffic

entesque dapibus efficitur laoreeffic

Fusce duiultrices

rem ipsum dolor sit amet, conso

iscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus