Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**********PLEASE ANSWER USING MATLAB********** NEED ANSWER PLEASE 1. An alternat

ID: 2080738 • Letter: #

Question

**********PLEASE ANSWER USING MATLAB**********

NEED ANSWER PLEASE

1. An alternative integration rule: A more precise rule for evaluating integral is called the "Euler Maclaurin rule" after the Euler s Maclaurin formula f(b) a +mh) 12 Where (b-aVN. This result gives a value for the integral has an error of order h a factor of h better than the error on the trapezoidal rule and as good as Simpson's rule. Write a program to calculate the value of the integral f(x) x 2x 1 between 0 s x S 2 using this formula. The order-h term in the formula is just the ordinary trap rules the term involves the derivatives fr ezoidal (a) and f'(b), which you should evaluate using central differences, centered on a and b respectively. Note that the size of the interval you use for calculating the central differences does not have to equal the value of h used in the trapezoidal rule part of the calculation. An interval of about 10 s gives good values for the central differences. Use your program to evaluate the integral with N 0 slices and compare the accuracy of the result with that obtained from the trapezoidal rule alone with the same number of slices.

Explanation / Answer

MATLAB_PATH = matlabroot; COMPILE_OPTIONS = ''; v = ver('matlab'); matver = sscanf(v.Version, '%d.%d.%d')'; COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMATLAB_VERSION=0x' sprintf('%02d%02d', matver(1), matver(2)) ]; MATLAB_VERSION = matver(1) + matver(2)/100; if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) ... || strcmpi('MACI', computer) || strcmpi('MAC', computer) ... || strcmpi('MACI64', computer) % GNU/Linux (x86-32 or x86-64) or MacOS (Intel or PPC) if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DSkip_f2c_Undefs',' -DNON_UNIX_STDIO']; else COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DSkip_f2c_Undefs']; end elseif strcmpi('PCWIN', computer) || strcmpi('PCWIN64', computer) % Windows (x86-32 or x86-64) if strcmpi('PCWIN', computer) if MATLAB_VERSION < 7.06; MANUFACTURER = 'lcc'; else cc = mex.getCompilerConfigurations('Any','Selected'); MANUFACTURER = cc.Manufacturer; end switch lower(MANUFACTURER) case {'lcc'} COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DLCCWIN32']; case {'microsoft'} case {'sybase'} COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DWATCOMWIN32']; otherwise disp('Try "mex -setup"!') end end else error('Unsupported platform') end % Large array dims for 64 bits platforms appeared in Matlab 7.3 if (strcmpi('GLNXA64', computer) || strcmpi('PCWIN64', computer) ... || strcmpi('MACI64', computer)) ... && ~(MATLAB_VERSION < 7.03) COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -largeArrayDims' ]; end % Comment next line to suppress optimization COMPILE_OPTIONS = [ ' -O' COMPILE_OPTIONS ]; % Comment next line to suppress compilation debugging info %COMPILE_OPTIONS = [ ' -v' COMPILE_OPTIONS ]; disp('Compiling polyroots...') eval(['mex ', COMPILE_OPTIONS, ' polyroots.c',' cpoly.c',' rpoly.c',' pow_di.c']);