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