How to calculate $\ln(x)$

$\begingroup$

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?

$\endgroup$ 1

7 Answers

$\begingroup$

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.

$\endgroup$ $\begingroup$

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.

$\endgroup$ $\begingroup$

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$.

$\endgroup$ 0 $\begingroup$

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

$\endgroup$ 4 $\begingroup$

Here is a really simple method that computes $\log_b(x)$ in base $10$ quickly on a non-scientific calculator. With practice you can do it very fast!

(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.

$\endgroup$ $\begingroup$

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.

$\endgroup$ $\begingroup$
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) 
$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like