4

I know only to calculate $\ln()$ using a calculator, but is there a way to calculate it without calculator:
for example: $\ln(4)= ??$ as far as I know the only way to do so is to draw the graph of $ln$ but it primarily depends on values from calculator. So really is there some formula for $\ln()$ to calculate its exact value for a specific number?

Mohammad
  • 357

8 Answers8

4

You could use it Taylor Series.

Define $$\operatorname{ln}(y) = -\operatorname{ln}(1-x) = \sum_{k=0}^{\infty}\frac{x^k}{k}$$ Then you are able to calculate the logarith for all real numbers $y>1$ with $y=\frac{1}{1-x}$


For real numbers $0<y\leq1$ you could use $$\operatorname{ln}(y) = (y-1)-\frac{(z-1)^2}{2} + \frac{(z-1)^3}{3} \mp \dots$$

instead

4

You can use the following definition for the natural logarithm: $$\ln t=\int_1^t\frac{1}{x}dx.$$ So $\ln t$ represents the area below the graph of $1/x$ from $x=1$ to $x=t$. You can easily approximate this area using the Trapezium Rule or other similar approximation methods.

Zugzwang14
  • 1,799
4

For a really efficient method, see The Arithmetic-Geometric Mean and Fast Computation of Elementary Functions. This paper showed how to obtain $\ln$ efficiently, from which all other elementary functions can be obtained with the same efficiency. Firstly $\exp$ can be obtained using Newton-Raphson approximation, but with each iteration carried out with precision being only proportional to the square of the error in the previous iteration, according to the proof I gave in another answer. (The starting value also needs to be computed carefully.) This would mean that the time taken in the last iteration is at least a constant fraction of the total time, and so computing $\exp$ has the same time complexity as $\ln$. Then using $\exp$ we can obtain $\cos$ and $\sin$ using $\cos(z) = \frac{e^{iz}+e^{-iz}}{2}$ and $\sin(z) = \frac{e^{iz}-e^{-iz}}{2i}$. Finally we can get $\tan$ from $\cos$ and $\sin$, and all their inverses using Newton-Raphson approximation again.

There is also a less efficient method that is simpler to understand, which proceeds by computing $\exp$ using argument reduction and then the identity $\exp(z) = \cos(z) + i \sin(z)$, followed by Taylor expansion for $\cos$ and $\sin$. Firstly, $\exp(z) = \exp( z \cdot 2^{-k} )^{2^k}$, and for $p$ bits of precision we can choose the minimum integer $m$ such that $z < 2^m$ and then the minimum integer $k > m + \sqrt{p}$. Then $| z \cdot 2^{-k} | < 2^{-\sqrt{p}}$, thus only $O(\sqrt{p})$ terms of the Taylor expansions are needed, which needs $O(\sqrt{p})$ multiplications at $(p+O(k))$ bits of precision. After that, the result is simply squared $k$ times, which only loses $O(k)$ bits of precision.

user21820
  • 57,693
  • 9
  • 98
  • 256
  • 1
    The inverse circular & hyperbolic functions can be obtained directly from the AGM algorithm, without any need of Newton-Raphson. – PM 2Ring Jan 07 '24 at 00:45
  • @PM2Ring: Thanks for your comment! It's nearly 10 yr later, but never too late for improvements! Though I'm mystified about the downvotes on both my answers, since I've actually used both methods and they work exactly as advertized. – user21820 Jan 16 '24 at 06:56
  • Voting on this site these days is a bit of a puzzle. (FWIW, I upvoted this answer). Maybe you got downvoted for posting 2 answers (even though that's a good idea when the answers are radically different). – PM 2Ring Jan 16 '24 at 07:09
  • @PM2Ring: Yea could be. The calculator method is really funny though. The errors accumulate fast for almost all calculators that only support √... XD – user21820 Jan 16 '24 at 07:39
3

For $t$ near $1$, you can use the Taylor series for $\ln(1+x) $, with $x=t-1$. For other values, you use tricks. For instance, $\ln4=-\ln1/4$. As $1/4$ is kind of far from $1$, it is better to use $\ln4=2\ln2=-2\ln1/2$.

Martin Argerami
  • 205,756
2

Fast method using non-scientific calculator

Here is a really simple method that computes $\log_b(x)$ in base $10$ quickly on a non-scientific calculator, for any real $x ≥ 1$ and $b > 1$. With practice you can do it very fast! (If $x < 1$, then $\log_b(x) = -\log_b(1/x)$.)

(1) Store $b$ into memory

(2) Input $x$

(3) Repeat the following once for each new digit:

  (3.1) Divide repeatedly by $b$ until it is below $b$ [usually by pressing "/ b = = = ..."]

  (3.2) The number of divisions needed is:

    (a) The part before the decimal point on the first iteration

    (b) The next digit after the decimal point on each subsequent iteration

  (3.3) Raise the result to the power of $10$ [usually by pressing "* =$^9$"]

Example

To compute $\log_3(7)$:

  Iteration 1:

    7 / 3 = 2.3333333333333333333333333333333

    Current approximation = $1.$

    * = 5.4444444444444444444444444444444

    = 12.703703703703703703703703703704

    = 29.641975308641975308641975308642

    = 69.164609053497942386831275720165

    = 161.38408779149519890260631001372

    = 376.56287151348879743941472336534

    = 878.64670019814052735863435451913

    = 2050.1756337956612305034801605446

    = 4783.7431455232095378414537079375

  Iteration 2:

    / 3 = 1594.5810485077365126138179026458

    = 531.52701616924550420460596754861

    = 177.17567205641516806820198918287

    = 59.058557352138389356067329727623

    = 19.686185784046129785355776575874

    = 6.5620619280153765951185921919581

    = 2.1873539760051255317061973973194

    Current approximation = $1.7$

    * =$^9$ 2507.2099294115051147692764117377

  Iteration 3:

    / 3 =$^7$ 1.146415148336307779958516877795

    Current approximation = $1.77$

    * =$^9$ 3.9212015032068844491180431713366

  Iteration 4:

    / 3 =$^1$ 1.3070671677356281497060143904455

    Current approximation = $1.771$

    * =$^9$ 14.55388896774681722318015529117

  Iteration 4:

    / 3 =$^2$ 1.61709877419409080257557281013

    Current approximation = $1.7712$

Note

The current approximation has the correct digits, but may not be the answer rounded to that number of digits.


How it works

Let $d_k$ be the number of divisions in the $k$-th iteration.
Let $x_k$ be the remaining number before the $k$-th iteration. $ \def\floor#1{\lfloor #1 \rfloor} $

Then $1 ≤ x/b^{d_1} < b$.
Thus $b^{d_1} ≤ x < b^{d_1+1}$.
Thus $d_1 ≤ \log_b(x) < d_1+1$.
Thus $d_1 = \floor{\log_b(x)}$.

For every $k∈ℕ⁺$ we have:
$x_{k+1} = \big( x_k/b^{d_k} \big)^{10}$.
${x_{k+1}}^{0.1}·b^{d_k} = x_k$.
$0.1·\log_b(x_{k+1}) + d_k = \log_b(x_k)$.
$\log_b(x_k) = d_k + 0.1·\log_b(x_{k+1})$.
and we also have:
$1 ≤ x_{k+1} < b^{10}$.
  Thus $0 ≤ \log_b(x_{k+1}) < 10$.
  And $0 ≤ d_{k+1} < 10$.

Therefore:
$\log_b(x) = \log_b(x_1)$
$ = d_1 + 0.1 · \log_b(x_2)$
$ = d_1 + 0.1 · ( \ d_2 + 0.1 · \log_b(x_3) \ )$
$ = d_1 + 0.1 · \big( \ d_2 + 0.1 · ( \ d_3 + 0.1 · \log_b(x_4) \ ) \ \big)$
$ \cdots $
  [Note that each of $d_2,d_3,d_4,\cdots$ and $\log_b(x_2),\log_b(x_3),\log_b(x_4),\cdots$ is in $[0,10)$.]

user21820
  • 57,693
  • 9
  • 98
  • 256
  • 1
    Here's a demo in Python: https://sagecell.sagemath.org/?z=eJxdUcFugzAMvfsrnrgAbRdglTZpKv2C3bYzCJTQWqOkool2qPrvc6DtuuXi%2DPk9O3mOoggffDj2Br3dJT6Fs2ibk0ELdmZsHNtBwa8k36IgejcOBTYlfNZWGhu0NEUBQlKd9bK40ARIw7oNLTfQWIqKWBm1kqRE11s7JjdGOvf1dS4lT7rm%5F5SahfQ14WFGxZer4swyT9BAyYSQVkVON9FUTKVa5A%2DN8ASZkNIDUgYkvDErcvxV0%2Dfen%2Dj%2Dl8DMr8xE18Xv9VmuSimKooioG%2D0Bh8btIeba0YWmRK3I1yonL%5FFVImnesTuFB77QceTBJdMWxO3gSWdHMHjA2Aw7k8zk9I0gJ5iYT7fvPcv2PLZizVwLxyOT%5FJ7KAmTIlM5z9Apm0GUcgzsZYnpZeazilGbxYhFMox941JJC&lang=python – PM 2Ring Jan 16 '24 at 11:23
  • 1
    @PM2Ring: Thanks for the demo! I'm so happy you're contributing so much to my answers. I'm a bit lazy to add an explanation and it's such an old post anyway.. For future readers who see this, the key idea is simply that you want to count how many 'times' you need to divide the input by b to reach 1. After dividing by some integer power of b, you are left with some remainder r in the range 1 to b. The number of 'times' r needs to be divided by b to reach 1 is just 1/10 times the number of 'times' r^10 needs to be divided by b to reach 1. – user21820 Jan 16 '24 at 12:32
  • 1
    @PM2Ring: I am perfectionist and have a preferred proof structure and added some technical details. Thanks for prodding me! =) – user21820 Jan 17 '24 at 07:14
1

There are several tricks that can help you calculate $\operatorname{ln}(4)$ or other such logarithms.

One trick is to write the number whose logarithm you want to calculate as a product of numbers that are as close to $1$ as possible. For example $$4 = 2^2 = \left(\frac{4}{3}\right)^2 \times \left(\frac{3}{2} \right)^2 = \left(\frac{4}{3}\right)^4 \times \left(\frac{9}{8} \right)^2 = \left(\frac{32}{27}\right)^4 \times \left(\frac{9}{8} \right)^6 = \left(\frac{256}{243}\right)^4 \times \left(\frac{9}{8} \right)^{10},$$ and so forth by dividing the fractions one by the other successively.

Do not go too far down this path as it will make some calculations painful. There is a trade-off between speed of convergence and difficulty of calculation. Writing $4$ as a product of powers of $64/63$, $126/125$, $225/224$ and $4375/4374$ is doable, but only worth it if you want very high precision on the first order of your approximation; it is better to calculate more terms on an easy Taylor series rather than having extremely fast convergence at the price of painful calculations.

The other trick you want to use is the $\operatorname{argth}$ function. $$\begin{equation} \operatorname{argth} \colon \left\{\begin{aligned} ]-1,1[ & \rightarrow\mathbb R \\ x & \mapsto \frac12 \operatorname{ln}\left(\frac{1+x}{1-x}\right) = \frac12 \left(\operatorname{ln}(1+x)-\operatorname{ln}(1-x)\right) \end{aligned}\right. \end{equation} $$ is the "odd part" of $x \mapsto \operatorname{ln}(1+x)$ and therefore its Taylor series is the odd half of that of $x \mapsto \operatorname{ln}(1+x)$, viz. $\operatorname{argth}(x) = \sum_{k=0}^{\infty} \frac{x^{2k+1}}{2k+1} $.

We have $ \operatorname{ln}(x) = 2\operatorname{argth}\left(\frac{x-1}{x+1}\right) $, using the definition of $\operatorname{argth}$.

Combining all we have seen,

$$ \operatorname{ln}(4) = 2 \operatorname{ln}(2) = 4\operatorname{argth}\left(\frac{1}{3}\right) $$

$$\operatorname{ln}(4) = 4 \operatorname{ln}\left(\frac{256}{243}\right) + 10 \operatorname{ln}\left(\frac{9}{8}\right) = 8\operatorname{argth}\left(\frac{13}{499}\right) + 20\operatorname{argth}\left(\frac{1}{17}\right). $$

Then use $$\operatorname{argth}\left(x\right) = \sum_{k=0}^{n} \frac{x^{2k+1}}{2k+1} + r_n(x),$$ with $$\forall x > 0, 0<r_n(x)<\frac{x^{2n+3}}{2n+3}\times\frac{1}{1-x^2}.$$

Using this on $$\operatorname{ln}(4) = 8\operatorname{argth}\left(\frac{13}{499}\right) + 20\operatorname{argth}\left(\frac{1}{17}\right), $$

and computing only the first term of each series, we have

$$\operatorname{ln}(4) = \frac{8\times13}{499} + \frac{20}{17}+\epsilon, $$

with $$\epsilon < \frac{8}{3}\times\left(\frac{13}{499}\right)^3\times1.001+ \frac{20}{3}\times\left(\frac{1}{17}\right)^3\times1.01$$ $$\epsilon < \frac{8}{3}\times\left(3\times10^{-2}\right)^3\times1.001+ \frac{20}{3}\times\left(6\times10^{-2}\right)^3\times1.01$$ $$\epsilon < 1.6 \times 10^{-3}.$$ Therefore $$\operatorname{ln}(4) = 1.3848...+\epsilon$$ $$1.3848<\operatorname{ln}(4) < 1.3865,$$ which is good considering the only "hard" calculation we did was to compute $ \frac{8\times13}{499} + \frac{20}{17}$.

We can get three more digits by adding the next term on each series : $\operatorname{ln}(4) = 1.38629...$, but at the cost of painful calculations. I had rather only do first order approximations on a better decomposition of $4$ (also using powers of $5$ and even $7$ for example) or calculate many terms only using $\operatorname{ln}(4)=4\operatorname{argth}\left(\frac13\right)$, getting one decimal per each new easily calculated term in the series (though you need to compute a division for each new term).

This all may seem complicated, but playing around with it you will see this method is actually easy to implement, very powerful and not too demanding (you only have two somewhat difficult divisions to compute), which is what you want when only using pen and paper.

EDIT: I checked that indeed any number $q\in G=\{2^α3^β5^γ7^δ/α,β,γ,δ\in\mathbb{Z}\}$ can be written as $q=\left(\frac{64}{63}\right)^a \left(\frac{126}{125}\right)^b \left(\frac{225}{224}\right)^c \left(\frac{4375}{4374}\right)^d$. Please note that $\left(G,\times\right)$ is a group isomorphous to $\left(\mathbb{Z}^4,+\right)$.

Let $$P=\left(b_1,b_2,b_3,b_4\right)=\left (\frac{64}{63},\frac{126}{125},\frac{225}{224},\frac{4375}{4374}\right)=\begin{bmatrix}6&1&-5&-1\\-2&2&2&-7\\0&-3&2&4\\-1&1&-1&1\end{bmatrix}$$ in the standard base $B=\left(2,3,5,7\right)$. $P$ is inversible and $$P^{-1}=\begin{bmatrix}19&30&44&53\\34&54&79&96\\27&43&63&76\\12&19&28&34\end{bmatrix}.$$

$4=\left(2,0,0,0\right)$ in the standard base $B$. In the new base, $4=\left(38,68,54,24\right)$. Ergo $$\operatorname{ln}(4)≈38\times\frac{2}{63+ 64}+68\times\frac{2}{125+126}+54\times\frac{2}{224+ 225}+ 24\times\frac{2}{4374+ 4375}=1.3862...$$ We have the first five digits on the first order calculation. Nice! The next order gives you four more digits. You can use $P^{-1}$ to compute the logarithm of any number in $G$ with a good convergence speed.

Axel
  • 303
  • 1
  • 7
  • For $11$, use $99/98$. $100/99$ and $121/120$ will mess up your matrix $P^{-1}$. $11=99/98 \times 98/9$. – Axel Jan 08 '24 at 11:33
1

There is no simple formula. There are lots of different methods, some simpler, some better, some usable if you want a million decimal digits of $\ln 4$. I'll show you what I think is the most elementary method; all it requires is that you calculate the number $e = 2.718...$ with enough precision. (However, the method works for base $10$ or base $2$ logarithms as well, and there you need no calculation to get the base).

The only serious maths that you need is that $\ln (e) = 1$, $\ln (xy) = \ln (x) + \ln (y)$, and $\ln (x^2) = 2 \ln (x)$.

To start the calculation of $\ln x$ for some $x > 0$, you start with a sum $s = 0$.

As long as $x ≥ e$, divide $x$ by $e$ and increase the sum $s$ by 1.

As long as $x < 1$, multiply $x$ by $e$ and decrease the sum $s$ by 1.

(If $x$ was equal to $e^n$ and therefore $\ln x = n$, you will have $x = 1$ and $s = n$ at this point. If $e^n ≤ x < e^{n+1}$, you will have $s = n$, and $x$ will be divided by $e^n$, so $1 ≤ x < e$).

Now calculate the square of $x$, that is $x = x^2$. If now $x ≥ e$, divide $x$ by $e$ and increase $s$ by $1/2$.

Calculate the square of $x$ again, and if $x ≥ e$, divide $x$ by $e$ and increase $s$ by $1/4$. Repeat this again and again, each time adding only half as much as in the previous step, until your result is precise enough for you.

This works because every time $x$ is squared, you double the logarithm. So to compensate for that, you only take half the logarithm of $x$, then a quarter, and so on.

This is by far not the most efficient way, but I think it's the easiest one to explain.

4yl1n
  • 320
gnasher729
  • 10,113
0
to find ln(a),
find n, such that e^n &lt a &lt e^(n+1)
x=a/e^n so that ln(a) = n + ln(x) and 1 &lt x &lt e
find y ,such that
x=(1+y)/(1-y)            (x>1 is assumed)
y=(x-1)/(x+1)
hence, ln(x)=ln(1+y)-ln(1-y)
            =2(y + y^3/3 + ...)
this converges rapidly as y &lt 1 always.
for x &lt 1, ln(x)=-ln(1/x)