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

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

View Full Document Right Arrow Icon
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);
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Page1 / 3

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online