Compute logarithms without using built-in functions