The reason Math.pow is so slow is because underneath, it's really doing:
fn pow(x, n): exp( n * ln(x) )
This is how you assure that power operations take constant time regardless of the input. However, exp and ln are relatively slow in numerical computing land, so if you're using small powers simply doing the multiplication out or if you're using powers of two, bit shifting will be faster.