What is the best way to calculate log without a calculator?

Solution 1:

This is a method I found a year ago. This method takes a lot of time but it will give an accurate answer.
To calculate log(25):
1) Divide 25 by the nearest power of 10. The condition must be 25 ≥ 10n.
2) The value of n is 1 because 25 ≥ 101. So the initial answer is 1.xxxxxx.
3) Divide 25 by 101. The result is 2.5.
4) Raise 2.5 by 10. So 2.510 ≈ 9536.7
(Note: The number is raised to 10 because we are already looking for the digits after the decimal point.)
5) For the next values, the same process will be used.
6) Divide 9536.7 by the nearest power of 10.
7) 9536.7 ≥ 103 so n=3. The answer is now 1.3xxxxx.
8) 9536.7 / 103 = 9.5367
9) Raise 9.5367 to 10. 9.536710 = 6222733625
10) 6222733625 ≥ 10n so n=9. The answer is now 1.39xxxx.
11) Repeat the same process until you get the desired precision.
12) So log (25) ≈ 1.39794.

This also works on logs with bases other than 10, even with decimals. In solving loga(x), just replace 10n with an. Also in solving for n, simply just divide the number by the base repeatedly until you get a quotient nearest to 1. The number of times you divided is n. (ie. 250/10= 25 (1), 25/10=2.5 (2), so n=2)

This is a method I had formulated on my own so I'm not saying that this is 100% reliable. It would be better to check your answer with a calculator. But I've tried this many times without flaws. No log tables, no need to memorize, just pure math.

Solution 2:

Calculating them to high precision is tedious, which is why the tables were once so important. The tables relied on interpolation formulae and inevitably contained errors, carried from book to book as a result of silent copying, sometimes for 200 years or more; errors in Vlacq and de Decker's table (1627) were still turning up in tables in the 19th century. This was one of Babbage's motivations for trying to construct a general purpose computer. Luckily, estimating a logarithm reliably to three or four decimal places isn't too hard if you are willing to memorize a handful of values and a simple formula.

Memorize $\log_{10}2,3,5,7$ and $\tfrac1{\ln10}\approx0.4343$.

(Note that $\log_{10}5=1-\log_{10}2$.) Then use $$\ln x\approx2\cdot\tfrac{x-1}{x+1}\text{ for }x\approx1$$ So for example $\log_{10}17=\log_{10}(2^4\cdot\tfrac{17}{16})=4\log_{10}2+\tfrac1{\ln10}\cdot\ln\tfrac{17}{16}$

And that's about $4\cdot0.30103+0.4343\cdot2\cdot\tfrac1{33}=1.23044\overline{12}$. True value: $1.2304489...$

Similarly $\log_{10}22=\log_{10}(3\cdot 7\cdot \tfrac{22}{21})=\log_{10}3+\log_{10}7+\tfrac1{\ln 10}\cdot\ln\tfrac{22}{21}$

Approximately $0.477121+0.845098+0.4343\cdot2\cdot\tfrac1{43}=1.342419$. True value: $1.34242268...$

Something like $\log_{10}3.57$ can be calculated as $-2+\log_{10}357$ which you can expand as $=-2+\log_{10}3+\log_{10}7+\log_{10}17\approx 0.55266$. True value: $0.5526682...$ In general the level of accuracy depends on how far you want to go in memorizing the logarithms of prime numbers.

Solution 3:

In case anybody wondered why the algorithm given by Ezui actually works, here is a little algebra to explain why:

The algorithm states, that to find the base $10$ logarithm of $x$ one should repeatedly carry out the following three steps:

  1. $d=\max(n\mid 10^n\leq x)$, store $d$ as the next digit
  2. $y=x/10^d$
  3. $x=y^{10}$

To prove the correctness, it suffices to prove that each "round" is correct. For simplicity, let $\log$ denote the base $10$ logarithm. First note that $d=\lfloor\log(x)\rfloor\in[0,\infty)\cap\mathbb Z$ is the integer part of $\log(x)$ and then $$ \begin{align} \log(y)&=\log(x/10^d)\\ &=\log(x)-d\in[0,1) \end{align} $$ where $\log(y)$ must be the fractional part of $\log(x)$. Thus we have $\log(x)=d+\log(y)$. Now, $\log(y^{10})=10\log(y)\in[0,10)$, so if determine $\log(y^{10})$ this result may be used to compute $\log(x)=d+\log(y^{10})/10$. The first digit of $\log(y^{10})$ is found in step 1. in the next "round" of the algorithm where $x=y^{10}$. So the algorithm is correct and produces a new digit of $\log(x)$ in each step.


For calculating $\log_b(x)$, the algorithm should be:

  1. $d=\max(n\mid b^n\leq x)$, store $d$ as the next digit
  2. $y=x/b^d$
  3. $x=y^b$

Solution 4:

A neat trick is to first reduce the problem to calculating the log of a number that's very close to 1, then use $\log{(1+x)}=\log{\frac{1+y}{1-y}}$ where $y=\frac{x}{2+x}$. Then use $$\log{\frac{1+y}{1-y}} = 2\sum_{n=0}^\infty\frac{y^{2n+1}}{2n+1}$$

This method is good because the error term converges much faster in the second expansion.

For example, $\log{2}=\log{\frac{1+1/3}{1-1/3}}=\log{\frac{1+1/7}{1-1/7}}-\log{\frac{1+(-1/5)}{1-(-1/5)}}=\log{\frac{1+1/7}{1-1/7}}+\log{\frac{1+1/5}{1-1/5}}$

Then $\log{\frac{1+1/7}{1-1/7}}= 2(1/7+1/(3\times7^3)+\cdots)$, $\log{\frac{1+1/5}{1-1/5}}= 2(1/5+1/(3\times5^3)+\cdots)$. Take only 2 terms, we get $$\log{\frac{1+1/7}{1-1/7}}\approx 2(1/7+1/(3\times7^3))=0.28766\cdots$$ $$\log{\frac{1+1/5}{1-1/5}}\approx 2(1/5+1/(3\times5^3))=0.40533\cdots$$ so $\log{2}\approx 0.28766+0.40533 = 0.69299$

The actual value is $\log{2}=0.69315\cdots$, so by just taking 2 terms from each expansion, we've already got a relative error of less than $3\times10^{-4}$.

Now, this method can be iterated to even more terms, and in general it would increase the accuracy, but at the price of making the formula more complicated.

Another way to accomplish the goal of achieving rapid convergence is by exploiting number coincidences (these two examples taken from section 7.7 of Introduction to Higher Mathematics by Hua Lo-Keng): $$4\log{2}=\log{\frac{16}{15}} + \log{3} + \log{5}$$ $$2\log{5}=\log{\frac{25}{24}} + 3\log{2} + \log{3}$$ $$4\log{3}=\log{\frac{81}{80}} + 4\log{2} + \log{5}$$ Let $a=\log{\frac{16}{15}}, b=\log{\frac{25}{24}}, c=\log{\frac{81}{80}}$, we get $$\log{2}= 7a+5b+3c, \log{3}= 11a+8b+5c, \log{5}= 16a+12b+7c$$.

Each $a, b, c$ is very close to $0$, so the serial expansion converges rapidly. For example, if we take 2 terms to calculate each of $a, b, c$, then: $$a=\log{(1+\frac{1}{15})}=\log{\frac{16}{15}}\approx 2(1/31+1/(3\times31^3))=0.0645385$$ similarly, $b=0.0408220, c=0.0124225$ then $\log{2}= 7a+5b+3c = 0.6931470$. Relative error is $\leq 3\times10^{-7}$

As a more dramatic example, the following can be used to calculate $\log_{10}{2}$, $\log_{10}{3}$, and $\log_{10}{41}$: calculating log(2)

The error analysis can be done by Taylor remainder. For example, $$|\log{\frac{1+x}{1-x}}-2(x+\frac{x^3}{3})|\leq 0.4|\frac{x^5(1+10x^2+5x^4)}{(1-x^2)^5}|$$ So if $|x|<0.3$, then the error is $$|\log{\frac{1+x}{1-x}}-2(x+\frac{x^3}{3})| \leq 1.3|x|^5$$.