Calculate logarithm by hand from the beginning

757 Views Asked by At

I want to calculate the logarithm of any base completely by hand. I don't want to use a calculator, tables or predefined numbers. The only mathematical functions available for the calculation are addition, subtraction, multiplication, division and if needed square root (which can be calculated by hand). I don't want an approximation.

There are two ways to do that:

The first is by brute-forcing / trial and error:

Example:

$\log_{10}(100)=?$

  • $10^4=10000$
    $10000 > 100$, so make exponent smaller.

  • $10^3=1000$
    $1000>100$, so make exponent smaller.

  • $10^2=100$
    So the solution for $\log_{10}(100)=2$

But this way of doing that is very limited and has no practical use.

The second is using lookup tables. But this is also very limited and you cant store a infinite amount of values.

I want to calculate it completely by hand. There is a Taylor Series for the natural logarithm:

$$\ln\left(1+x\right)=\frac{x^1}{1!}-\frac{x^2}{2!}+\frac{x^3}{3!}-\frac{x^4}{4!}+\frac{x^5}{5!}\cdots$$

Is it maybe possible to use this for solving any logarithm?

2

There are 2 best solutions below

10
On

Almost all logarithms of almost all numbers in almost all bases are in fact irrational. When you say you don't want an approximation, how do you plan to write down these irrational numbers exactly? (By the way, the same goes for square roots: there's an algorithm for them, but for almost all inputs, computing the output exactly requires infinitely many steps.) If you're willing to allow infinitely many steps, then the Taylor series (with a little preliminary work) will do fine.

Here's a solution for when then base $b$ is bigger than $1$; I leave the other case to you.

The preliminary work is this: take your input (positive) number $x$. If it's between $1$ (inclusive) and $2$ (exclusive), write down $0$, and move on to the real work below, renaming your number $x''$.

Otherwise, if it's less than $1$, multiply $x$ by $b$ until you get a number $x'$ that's between $1$ (inclusive) and $b$ (exclusive). If you multiplied by $b$ some number, $k$, times, write down $-k$. $$ \log_b(x) = \log_b(x') + \log_b(b^{-k} = \log_b(x') -k $$ so all you need to do is compute $\log_b(x')$. A similar approach works for numbers larger than $b$.

So...after some number of multiplications/divisions by $k$, you get to a number $x'$ between $1$ and $k$. If $1 \le x' < 2$, move on; otherwise, compute the square root, and get that $$ \log_b(x') =2 \log_b \sqrt{x'}, $$ so you only need to compute the log of that square root. Repeatedly extract square roots until you get a number less than $2$, call it $x''$. Move on to the "real work" portion.

If $x$ is bigger than $b$, divide $x$ by $b$ until you get a number $x'$ that's between $1$ and $b$ as above. If you divided $k$ times, write down $+k$, and use this to show how $\log x'$ is related to $\log x$. Then use square roots, as before, to reduce to a number between $1$ and $2$, and call that $x''$.

The "real work": Now use the Taylor series (for $\log$, of course!) to compute $p = \log x''$; that'll take infinitely long in general, but you already indicated by your willingness to extract square roots that this was OK.

Your final answer for $\log x$ is $\frac{p}{\log b}$ plus the adjustments from the preliminary phases. Of course, this requires that you compute $\log b$... which you can do using the second phase (to reduce $b$ to a number smaller than $2$) and the third (using the Taylor series).

Thanks to @DavidK for pointing out that in an earlier version I was assuming convergence of the series for $\log_b$ on $1 \le u < b$, when I should only have used $1 \le b < 2$.

Note too, that if you like square roots, you can skip the first phase and just take square roots for longer (at least if $x$ starts out larger than $b$).

====

I don't claim any efficiency here. You win BIG by dividing/multiplying at least once more by $\sqrt{b}$, and then adding/subtracting $\frac12$ from the result, because convergence of the Taylor series is a LOT faster when you're in the first half of the domain of convergence.

N.B.: For an arbitrary input $x$ and base $b$, even expressing these numbers is likely to take infinitely long.

4
On

Here are two methods of calculating any logarithm at all, though neither is of particularly rapid convergence.

My favorite is to use the little-known formula $$ \ln(x)=\lim_{n\to\infty}n\bigl(x^{1/n}-1\bigr)\,. $$ The limit is over all values of $n$, so you might as well restrict to $n=2^m$. On my trusty HP15C, I can do this by entering $x$, then hitting the square-root button $m$ times. Then I subtract $1$, and multiply by $2^m$. Try it.

Of course that’s only an approximation, and if you want something close, I fear that you need to go to unreasonably large values of $m$, not really practical.

Here’s a series, however, good for all $x$: notice that $\ln(1-x)=-\bigl(\sum_{n=1}^\infty\frac{x^n}n\bigr)$, and therefore we get $$ \ln\left(\frac{1+x}{1-x}\right)=2\sum_{n=0}^\infty\frac{x^{2n+1}}{2n+1}\,, $$ still valid only for $-1<x<1$. But that’s good enough for our purposes: solve $\xi=\frac{1+x}{1-x}$ for $x$, and get $x=\frac{\xi-1}{\xi+1}$. Thus, for instance, if you want $\ln5$, you set $\xi=5$, $x=\frac46=\frac23$. That’s what you plug into the series above to get $\ln(5)$.

To get $\log_b(x)$, you need only $\ln b$ and $\ln x$, as I’m sure you know.