Why does my calculator compute ln(5) faster than ln(e)?

  • Context: High School 
  • Thread starter Thread starter NoOne0507
  • Start date Start date
  • Tags Tags
    Calculator
Click For Summary

Discussion Overview

The discussion centers around the differing computation times for the natural logarithm of 5 compared to that of e on calculators. Participants explore potential reasons for this discrepancy, including the methods used for calculating logarithms and the implications of numerical representation.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest that the logarithm of 5 is computed faster because it is a simple integer, while the logarithm of e requires more complex calculations, such as limits or series expansions.
  • Others propose that calculators may utilize different algorithms for integer logarithms, although this idea is challenged as potentially unnecessary and overly complicated.
  • One participant mentions that the binary representation of 5, having fewer 1 bits, could lead to faster calculations, especially on older processors with limited capabilities.
  • Another participant points out that the term "power series" may be misleading, as logarithms are often computed using more efficient methods, such as the ratio of cubic polynomials, rather than Taylor series.
  • Concerns are raised about the historical accuracy of early calculators, which may have used inefficient numerical methods, while modern calculators are expected to perform better.
  • A personal observation is shared that no noticeable speed difference exists on a specific calculator model when comparing the logarithms of 5 and e.

Areas of Agreement / Disagreement

Participants express differing views on the methods used for logarithm calculations and whether specific algorithms are employed for integers. The discussion remains unresolved with multiple competing perspectives on the topic.

Contextual Notes

Some assumptions about calculator design and numerical methods are not explicitly stated, and there is a lack of consensus on the efficiency of various algorithms for computing logarithms.

NoOne0507
Messages
15
Reaction score
0
Straightforward question for anyone who knows how calculators work.
 
Mathematics news on Phys.org
First thought. 5 is a simple integrer. e is calculated as a limit or by series expansion.
 
Yes, I think it's a reasonable explanation. The ln is computed using the power series, so it's considerably faster with natural numbers.
 
Okay. Makes sense, thanks.
 
You think there is a separate code for calculating logarithms of integer numbers? That would be rather unexpected - and I don't see a reason for such approach. Unnecessary complication.
 
Borek said:
You think there is a separate code for calculating logarithms of integer numbers? That would be rather unexpected - and I don't see a reason for such approach. Unnecessary complication.

The binary representation of 5 will have only 2 1 bits, so multiplying by it will be much faster, espescially on a very old processor with only 8 (or even 4) bits, and no multiplication instruction. (and it has to be something like that, or the calculation time would be too fast to notice a delay).

Actually the calculator may begin with ln(5) = 2 * ln(2) + ln(1.25), and then use the power series expansion of ln(x) around x = 1, so you end up with powers of 1/4, so you have only 1 bit to multiply by.
 
A couple of posts here have used the words "the power series", as if there was only one such thing. Presumably they mean a Taylor series that they learned about in a calculus course.

That is very rarely the way functions like logs are calculated in "serious" numerical work. For example one well-known method of calculating logs uses the ratio of two cubic polymonials, and is accurate to 16 decimal places in the range \sqrt {1/2} \le x \le \sqrt 2. That is much quicker than using enough terms to get the same accuracy from a Taylor series. (Ref: Plauger, "The Standard C library" - though the algorithm comes from an earlier book by Cody & Waite)

Having said that, some of the early electronic calculators (back in the 1970s) used horrible numerical methods. IIRC it was possible to send one of the early Sinclair calculators into an "infinte loop" evaluating some math functions, but with modern electronics there's no excuse for that sort of thing.

It's possible that some calculators do all their arithmetic in decimal rather than binary, and do multiplications the same way as doing long multiplication by hand. In that case it's possible that a value with a small number of non-zero digits will compute faster, if the program skips over doing operations on the zeros.

FWIW on my calculator (a Casio) I can't detect any speed difference in the OP's example, and I haven't noticed anything similar for other functions.
 

Similar threads

  • · Replies 44 ·
2
Replies
44
Views
5K
  • · Replies 171 ·
6
Replies
171
Views
11K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 15 ·
Replies
15
Views
5K