# P15_5b - if fxlxr(i,1) &amp;amp;gt; 0 xu(i+1,1) = xu(i,1);...

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

%Problem 15.5 % function P15_5b f x = [1 2 3 4 5 6 7]; x y = [3.6 1.8 1.2 0.9 0.72 1.5 .51429]; y xest = [1 2 3 4]; x yest = [3.6 1.8 1.2 0.9]; y coefs = polyfit(xest, yest, 3) c %F = coefs(1,4) + coefs(1,3).*X + coefs(1,2).*X.^2 + coefs(1,1).*X.^2; % %bracket between x = 2 and x = 3 % xl(1,1) = 1; xu(1,1) = 4; x fxlxr = zeros(3,1); f Ea = zeros(3,1); E Ea(1,1) = 0; E i = 1; i while Ea > E xr(i,1) = (xl(i,1) + xu(i,1))/2; fxl(i,1) = f(xl(i,1)); fxr(i,1) = f(xr(i,1)); fxlxr(i,1) = f(xl(i,1))*f(xr(i,1));

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.

Unformatted text preview: if fxlxr(i,1) &gt; 0 xu(i+1,1) = xu(i,1); xl(i+1,1) = xr(i,1); else xl(i+1,1) = xl(i,1); xu(i+1,1) = xr(i,1); end if i == 1 else Ea = abs((xr(i,1)-xr(i-1,1))/xr(i,1))*100; end i = i+1; end xr(i-1,1) function new = f(X) f xest = [1 2 3 4]; x yest = [3.6 1.8 1.2 0.9]; y coefs = polyfit(xest, yest, 3); c new = coefs(1,4) + coefs(1,3)*X + coefs(1,2)*X^2 + coefs(1,1)*X^3 - 1.6;...
View Full Document

## P15_5b - if fxlxr(i,1) &amp;amp;gt; 0 xu(i+1,1) = xu(i,1);...

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

View Full Document
Ask a homework question - tutors are online