#include using namespace std; namespace proper { double inverse(double x) { return 1.0/x; }// inverse } namespace quick { double inverse(double x) { return 2-x; // why?! }// inverse } int main() { cout << proper::inverse(1.005) << endl; cout << quick::inverse(1.005) << endl; return(0); }// main() /* How is 1/x ~= 2-x? (1+dx)*(1-dx) = 1-(dx*dx) For SMALL dx, (dx*dx)~0, can be omitted. So (1+dx)*(1-dx) ~ 1, which means 1/(1+dx) ~ (1-dx) How would we return (1-dx), in terms of our input x (which is 1+dx)? x = 1+dx [by defn] dx= x-1 (eg. 1.005-1, ie. .005) 1-dx = 1-(x-1) = 2-x, this is what we return :) Eg. 1/1.004 ~= 2-1.004, ie. 0.996 [same as 1-0.004] */