lab14partialsoln - // root finding by bisection on which...

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

View Full Document Right Arrow Icon
// Partial solution to Lab 14 // PRE: // function f is defined and continuous on [leftPt, rightPt], // and IsRootAccepted(x, leftPt, rightPt) == false, // thus exactly one of these cases is true: // 1. f(midpoint) and f(leftPt) have different signs // 2. f(midpoint) and f(rightPt) have different signs // POST: leftPt or rightPt is reset to the midpoint for whichever case, 1 or 2, // is true, thus we have a smaller interval for the next iteration of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // root finding by bisection on which the Intermediate Value Theorem // guarantees a solution { if(f(leftPt)*f(midpoint) < 0) // (-)*(+) == (-) so signs differ { // so f must cross x-axis on the left rightPt = midpoint; // so use left subinterval } // and discard the right subinterval else // signs are same { // so f must cross x-axis on the right leftPt = midpoint; // so use right subinterval } // and discard the left subinterval }...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online