{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

eval_integral

# eval_integral - function eval_integral(y,l,u%Problem...

This preview shows pages 1–2. Sign up to view the full content.

function eval_integral(y,l,u) %Problem 17.2 % %This program is designed to pass any expression that is to be integrated %into this function and (a) solve analytically, (b) apply single %application of the trapezoidal rule (c) apply composite trapezoidal rule %with n=2 and n=4, (d) apply application of Simpson's 1/3 rule, (e) apply %composite Simpson's 1/3 rule with n=4, and (f) apply Simpson's 3/8 %rule. The percent relative errror will be calculated for steps (b)-(f). % %x is the expression that is passed into the function %by means of an anonymous function. %u=upper limit %l=lower limit if nargin<3, error('must enter a function, lower and upper limits'); end %(a) Evaluate integral analytically syms x yy=int(y,x,l,u); a=eval(yy); %Actual value determined analy. fprintf('\n(a) %10.9f\n\n',a); %(b) Single application of teh trapezoidal rule fb=y(u); fa=y(l); I=(u-l)*(fb+fa)/2; Et=a-I; %Error et=(Et/a)*100; %Percent relative error=(actual-theo)/act*100% fprintf('(b) %6.5f, et=%4.2f\n\n',I,et);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

eval_integral - function eval_integral(y,l,u%Problem...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online