Answer to Question #8120 in Programming & Computer Science for kenry

Question #8120
Expert... help me on this problem, i already try many times during this 2 week, but i cant the answer by using m-files.


Determine the real root of f(x)=-26+85x-91x^2+44x^3-8x^4+x^5
Using bisection to determine the root to εs=10 %. Employ initial guesses of xl=0.5 and xu=1.0.
You need to solve the above problem using Matlab
1
Expert's answer
2012-04-05T09:21:38-0400
function
[c,err,yc]=bisection(f,a,b,err_tolerance)
ya=feval(f,a);
yb=feval(f,b);
if
ya*yb >
0,return,end
maxx=1+round((log(b-a)-log(err_tolerance))/log(2));
for
k=1:maxx
c=(a+b)/2;
yc=feval(f,c);
if yc==0
a=c;
b=c;
elseif
yb*yc>0
b=c;
yb=yc;
else
a=c;
ya=yc;
end
if b-a <
err_tolerance, break,end
end
c=(a+b)/2;
err=abs(b-a);
yc=feval(f,c);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

kenry
06.04.12, 07:11

but y it appear those error comment? ??? Error: File: Untitled.m Line: 6 Column: 1 Function definitions are not permitted in this context.... tis error come out by the "function" word...

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS