The reason Math.pow is so slow is because underneath, it&#x27;s really doing:<p><pre><code>    fn pow(x, n): exp( n * ln(x) )
</code></pre>
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&#x27;re using small powers simply doing the multiplication out or if you&#x27;re using powers of two, bit shifting will be faster.