Optimizing pow()

The implementation of xa can be optimized for constant a .

It is obvious that for constant integer exponent you can just expand:

x3 = x1x2
x9 = x1x8

and since 1310 = 11012 = 20 + 22 + 23 :

x13 = x1x4x8

Likewise for fractional a :

x(3)/(4) = x(1)/(2)x(1)/(4)

So for a = 2.410≃10.0110011012 :

x2.4x2x(1)/(4)x(1)/(8)x(1)/(64)x(1)/(128)x(1)/(512)