Bisection - fL = f(L fR = f(R tol = 10^-6(R-L while...

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

View Full Document Right Arrow Icon
function xStar = Bisection(f,L,R) % f is a handle to a continuous function f(x) of a single variable. % L and R define an interval [L,R] and f(L)f(R) < 0 % % xStar is an approximate root of f with the property that it % is within |R-L|/10^6 of a true root.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % fL = f(L); fR = f(R); tol = 10^-6*(R-L); while abs(R-L) > tol mid = (L+R)/2; fmid = f(mid); if fL*fmid<=0 % There is a root in [L,mid]. R = mid; fR = fmid; else % There is a root in [mid,R]. L = mid; fL = fmid; end end xStar = (L+R)/2;...
View Full Document

This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell.

Ask a homework question - tutors are online