Proofs of Algorithm Correctness and Runtime Estimates · Polynomial, Exponential, and Logarithmic Functions

Lesson 3

Nikolai Chukhin · Alexander S. Kulikov

This is how one could arrive at the answer. \[\begin{align*}\frac{\left(18^3\right)^{2^3} \cdot 9^{-20}}{24^7}&=\frac{\left(\left(2 \cdot 3^2\right)^3\right)^{8} \cdot \left(3^2\right)^{-20}}{\left(2^3\cdot 3\right)^7}&\text{(decompose each number into primes)}\\&=\frac{\left(2^3 \cdot 3^6\right)^{8} \cdot 3^{-40}}{2^{21}\cdot 3^7}&\text{(\((a^{p})^{q}=a^{pq}\), \((ab)^{p}=a^{p}b^{p}\))}\\&=\frac{2^{24} \cdot 3^{48} \cdot 3^{-40}}{2^{21}\cdot 3^7}&\text{(\((a^{p})^{q}=a^{pq}\))}\\&=2^{24}\cdot 3^{48}\cdot 3^{-40}\cdot 2^{-21}\cdot 3^{-7}&\text{(\(1/a^{p}=a^{-p}\))}\\&=2^{24-21}\cdot 3^{48-40-7}&\text{(\(a^{p}a^{q}=a^{p+q}\))}\\&=2^{3} \cdot 3\\&=24.\end{align*}\]

The answer can also be found in Python:

print((18 ** 3) ** (2 ** 3) * (9 ** (-20)) / 24 ** 7)

24.0
However, it is important to remember that if intermediate expressions become too large, Python will not cope.
print((10 ** 1000) / (10 ** 99))

print((10 ** 1000) / (10 ** 99))
          ~~~~~~~~~~~~~^~~~~~~~~~~~
OverflowError: integer division result too large for a float