{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lab14partialsoln

# lab14partialsoln - root finding by bisection on which the...

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

// Partial solution to Lab 14 void ResetEndpoints(double midpoint, double & leftPt, double & rightPt) // PRE: Assigned(midpoint) && leftPt < rightPt, // 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
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

{[ snackBarMessage ]}