3 #include "MathFunctions.h"
5 // include the generated table
8 // a hack square root calculation using simple operations
9 double mysqrt(double x)
15 // use the table to help find an initial value
17 if (x >= 1 && x < 10) {
18 std::cout << "Use the table to help find an initial value " << std::endl;
19 result = sqrtTable[static_cast<int>(x)];
23 for (int i = 0; i < 10; ++i) {
27 double delta = x - (result * result);
28 result = result + 0.5 * delta / result;
29 std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;