/* efficiantly compute x^n */ double pow(double x; int n) { double y = 1; int neg = (n < 0); if (neg) n = -n; while (n) { if (n & 1) y *= x; x *= x; n >>= 1; } return neg ? 1.0/y : y; }