Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The constraints of this question is related to a programming problem, but I must get the math right in order for it to be applied to code. The actual problem is I need a function that evaluates to log base 10 but all I have at my disposal is addition, subtraction, multiplication, division, a powering function, and a natual log function. Is there a way to effectively evaluate log base 10 with the given operations?

On a side note, I seem to remember having to do some division with logs in order to change the base, but it's been forever ago (who knew those college math classes would come in handy!)

share|cite|improve this question
This is the formula you are looking for $log_{10}a=\frac {log a}{log 10}$ – azarel Feb 9 '12 at 19:47
up vote 7 down vote accepted

The change of base formula does it.
$$\log_{10}(x) = {\ln(x)\over \ln(10)}.$$

share|cite|improve this answer

You do not have to memorize the change of base formula:

Say you want to evaluate $\log_{a}(x)$. Let's call it $y$. Then:

$$\begin{align} y = \log_{a}(x) &\iff a^y = x \\ & \iff \ln(a^y) = \ln(x) \\ & \iff y \ln(a) = \ln(x) \\ &\iff y = \frac{\ln(x)}{\ln(a)}. \end{align}$$

This shows that $\log_{a}(x) = \frac{\ln(x)}{\ln(a)}$, but hopefully this also emphasizes that you need not memorize the change of base formula in order to use it.

share|cite|improve this answer

You can change the base of logarithm with this formula:

$$ \log_ax=\frac{\log_bx}{\log_ba} $$

So taking $a=e$ and $b=10$ will give you desired transformation.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.