2 #include "MathFunctions.h"
3 #include "TutorialConfig.h"
5 // include the generated table
10 // a hack square root calculation using simple operations
11 double mysqrt(double x
)
20 // if we have both log and exp then use them
23 // use the table to help find an initial value
27 result
= sqrtTable
[static_cast<int>(x
)];
32 for (i
= 0; i
< 10; ++i
)
38 delta
= x
- (result
*result
);
39 result
= result
+ 0.5*delta
/result
;
40 fprintf(stdout
,"Computing sqrt of %g to be %g\n",x
,result
);