Problem set #7 - Egm 3344 Problem Set #7 Sorting Number 26...

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

View Full Document Right Arrow Icon
Egm 3344 Problem Set #7 Sorting Number 26 Problems Completed 17.2; 17.5; 17.6; 18.3; 19.1; 19.4; (19.9/2); 19.11 % Problem Problem 17.2
Background image of page 1

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

View Full DocumentRight Arrow Icon
function Prob17_2 format long func = @(x) 1 - exp(-2*x); x1 = 0; x2 = 4; % a) real value of integral int = @(x) x + (1/2)*exp(-2*x); real = int(4) - int(0) format short % b) Single application of Trapazoidal rule a = func(x1); b = func(x2); PartB = ((b + a)/2) * (x2 - x1) Et = ((PartB - real) / real)*100 % c) Composite Trapozoidal rule n = 2; h = (x2-x1)/n; x = x1; f = func(x1); for i = 1:n-1 x = x + h; f = f + 2*func(x); end f = f + func(x2); PartC1 = (x2 - x1)* f/(2*n) Et = abs(((PartC1 - real) / real)*100) n = 4; h = (x2-x1)/n; x = x1; f = func(x1); for i = 1:n-1 x = x + h; f = f + 2*func(x); end f = f + func(x2); PartC2 = (x2 - x1)* f/(2*n) Et = abs(((PartC2 - real) / real)*100) % Single application of Simpson's 1/3 rd rule n = 2; h = (x2-x1)/n; PartD = (h/3)*(func(0) + 4*func(2) + func(4)) Et = abs(((PartD - real) / real)*100) % Composit application of Simpson's 1/3 rd rule n = 4; h = (x2-x1)/n; PartE = (x2 - x1) * (func(x1) + 4*(func(x1 + h) + func(x1 + 2*h)) ... + 2*func(x1 + 3*h) + func(x1 + 3*h))/(3*n) Et = abs(((PartE - real) / real)*100) % Single application of Simpson's 3/8 ths rule x = linspace(0,4,4); PartF = (x2 - x1) * (func(x(1)) + 3*func(x(2)) ... + 3*func(x(3)) + func(x(4)))/8 Et = abs(((PartF - real) / real)*100) OUTPUT
Background image of page 2
real = 3.500167731313951 PartB = 1.9993 Et = -42.8790 PartC1 = 2.9630 Et = 15.3460 PartC2 = 3.3437 Et = 4.4702 PartD = 3.2843 Et = 6.1683 PartE = 3.4593 Et = 1.1670 PartF = 3.3884 Et = 3.1942
Background image of page 3

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

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

Page1 / 12

Problem set #7 - Egm 3344 Problem Set #7 Sorting Number 26...

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

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