# log2 = How to aproximate.....

**URL:** https://boards.straightdope.com/t/log2-how-to-aproximate/292045
**Category:** Factual Questions
**Created:** [February 26, 2005, 8:21pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045 "2005-02-26T20:21:43Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![HPL](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@HPL](https://boards.straightdope.com/u/HPL)
#### Post date: [February 26, 2005, 8:21pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/1 "2005-02-26T20:21:43Z")

</div>

I need to calcuate something to the log2. Unfortunatly, my caculator(a scientific calculator) does not have that function.

How do I aproximate it with other keys(I have LOG and LN, as well as the standred set).

---

<div class="post-metadata">

### Author: ![Splanky](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Splanky](https://boards.straightdope.com/u/Splanky)
#### Post date: [February 26, 2005, 8:26pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/2 "2005-02-26T20:26:28Z")

</div>

You could always use the Taylor series for logs 🙂

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [February 26, 2005, 8:28pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/3 "2005-02-26T20:28:24Z")

</div>

Use the change of base formula. log[sub]2/sub = ln(x)/ln(2).

---

<div class="post-metadata">

### Author: ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)
#### Post date: [February 26, 2005, 8:29pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/4 "2005-02-26T20:29:24Z")

</div>

Do you mean a base 2 logarithm? If so, log2(x)=log(x) / log(2), where the logs on the right hand side are any base you like (as long as you use the same base for both).

---

<div class="post-metadata">

### Author: ![Splanky](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Splanky](https://boards.straightdope.com/u/Splanky)
#### Post date: [February 26, 2005, 8:30pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/5 "2005-02-26T20:30:32Z")

</div>

Basically, ln(x+1) = x - (x^2)/2 + (x^3)/3 - … with the domain [-1,1].

So, ln2 = 1- 1/2 + 1/3 -(1/4)…

Of course that’s the natural log. I’m not sure what base you want.

---

<div class="post-metadata">

### Author: ![Splanky](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Splanky](https://boards.straightdope.com/u/Splanky)
#### Post date: [February 26, 2005, 8:31pm UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/6 "2005-02-26T20:31:48Z")

</div>

Oops. I think I misread, you want to know how to find something in base 2. Ignore my post.

---

<div class="post-metadata">

### Author: ![KP](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@KP](https://boards.straightdope.com/u/KP)
#### Post date: [February 27, 2005, 12:22am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/7 "2005-02-27T00:22:03Z")

</div>

I constantly find myself doing math in my head, even in this age of calculator (even though a calculator watch was my preferred timepiece until 5-7 years ago).

Though the the answer given earlier, which can be generalized as:

**log[sub]2/sub = log[sub]x/sub/ log[sub]x/sub**  
_(where log[sub]a/sub is the log of B in the base a)_

is exactly accurate, it overlooks a fact I use almost daily: in quick approximations, \*\*log[sub]10/sub is a wonderfully convenient 0.3 (actually 0.3010299957… but that’s an error of only 0.003421 or ~1/3 of a percent, which I can usually live with. Besides I know the correct value, so I can correct for it in my head)

Okay, so I was a math geek as a kid and never outgrew it. I wouldn’t advise making anything of that: I was also a martial arts geek.

---

<div class="post-metadata">

### Author: ![KP](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@KP](https://boards.straightdope.com/u/KP)
#### Post date: [February 27, 2005, 12:25am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/8 "2005-02-27T00:25:55Z")

</div>

Make that: **log[sub]10/sub is a wonderfully convenient 0.3** (actually 0.3010299957…)

I never claimed to be a UBB code geek.

---

<div class="post-metadata">

### Author: ![wolf\_meister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolf_meister/32/15202_2.png) [@wolf\_meister](https://boards.straightdope.com/u/wolf_meister)
#### Post date: [February 27, 2005, 2:03am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/9 "2005-02-27T02:03:42Z")

</div>

Or try the handy calculator at:  
[http://www.1728.com/logrithm.htm](http://www.1728.com/logrithm.htm)  
It will compute logs in ANY base.

---

<div class="post-metadata">

### Author: ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)
#### Post date: [February 27, 2005, 3:27am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/10 "2005-02-27T03:27:22Z")

</div>

The OP’s question has been well answered (by **ultrafilter** and others), but I thought I’d show the derivation of this formula.

log[sub]2/sub is by definition y, where y is the exponent so that 2[sup]y[/sup] = x.

Take logs of both sides of this equation (ln is most natural, heh heh, but “common” logs will do just as well):

ln 2[sup]y[/sup] = ln x

Then y ln 2 = ln x by one of the magical properties of logarithms.

Finally, solving for y yields y = ln x / ln 2.

This gives the exact answer, not an approximation (except insofar as your calculator can only give you so many digits), and is easy enough to do that most calculator manufacturers don’t see the point of including a special key for logs to other bases.

---

<div class="post-metadata">

### Author: ![TJdude825](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@TJdude825](https://boards.straightdope.com/u/TJdude825)
#### Post date: [February 28, 2005, 6:58am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/11 "2005-02-28T06:58:17Z")

</div>

If you have a TI-83 or similar, you can write a very simple program to do this for you, using the “change of base formula” mentioned above:

```auto

:Disp "LOGARITHM"
:Input "BASE ",B
:Input "OF ",X
:Disp ln(X)/ln(B)

```

And that’s less than 60 bytes.

---

<div class="post-metadata">

### Author: ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)
#### Post date: [February 28, 2005, 7:35am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/12 "2005-02-28T07:35:53Z")

</div>

If you have access to a linux box, it likely has bc installed. Be sure to invoke it as “bc -l” to preload the math library.

the function l() is natural log, so to get log (base 2) of 64:

enter  
l(64)/l(2)  
and it will say  
6.000000000000

---

<div class="post-metadata">

### Author: ![HPL](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@HPL](https://boards.straightdope.com/u/HPL)
#### Post date: [March 1, 2005, 7:22am UTC](https://boards.straightdope.com/t/log2-how-to-aproximate/292045/13 "2005-03-01T07:22:58Z")

</div>

Thanks for the help. I appreciate it.
