bisection2 - if xr~=0, ea=abs((xr-xrold)/xr);end...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function xr=bisection2(func,xl,xu,es,maxit) %Problem 5.8 using bisection method test=func(xl)*func(xu); if test>0,error('no sign change'),end iteration=0; xr=xl; while(1) xrold=xr; xr=(xl+xu)/2; iteration=iteration+1;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if xr~=0, ea=abs((xr-xrold)/xr);end test=func(xl)*func(xr); if test<0 xu=xr; elseif test>0 xl=xr; else ea=0; end if ea<=es||iteration>=maxit,break, end end...
View Full Document

Ask a homework question - tutors are online