SquareRootF - { // lower <= square-root(n) <= upper...

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

View Full Document Right Arrow Icon
/* Comptuing square roots. Author: Eric Van Wyk, Ted Kaminski. Date: Feb 22, 2010 */ double mysqrt(double n, double accuracy) { double lower = 1.0 ; double upper = n ; // lower <= square-root(n) <= upper while ( (upper - lower) > accuracy )
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { // lower <= square-root(n) <= upper double guess = 0.0 ; guess = (lower + upper) / 2.0 ; if ( guess*guess > n ) upper = guess ; else lower = guess ; } return (lower + upper) / 2.0; }...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online