## LOG bases

Discussion around the Swiss Micros DM42 calculator.
jneven
Posts: 9
Joined: Sat Jan 23, 2021 6:32 pm
Location: Belgium

### Re: LOG bases

Walter wrote:
Sat Mar 20, 2021 11:13 am
Calambres wrote:
Sat Mar 20, 2021 9:52 am
Thomas Okken wrote:
Fri Mar 19, 2021 7:29 pm
LOGb(X) = LN(X)/LN(b)
...is slightly faster
Just curious: why is it faster a LN than a LOG?
Because LN is calculated while LG is derived from LN.
I did a small test with 5000 times LOG(X)/LOG(B) against LN(X)/LN(B). With LOG it was 17.6 seconds and with LN it was 18.05 seconds. Wondering why, I did the test without the division. There the LN version was 14.2 seconds and the LOG version 14.85 seconds. So, Thomas, the faster division compensates for the slower LOG and makes the LOG version slightly faster .
toml_12953
Posts: 729
Joined: Wed May 03, 2017 7:46 pm
Location: Malone, NY USA

### Re: LOG bases

Walter wrote:
Sat Mar 20, 2021 11:13 am
Calambres wrote:
Sat Mar 20, 2021 9:52 am
Thomas Okken wrote:
Fri Mar 19, 2021 7:29 pm
LOGb(X) = LN(X)/LN(b)
...is slightly faster
Just curious: why is it faster a LN than a LOG?
Because LN is calculated while LG is derived from LN.

(Nitpicky remark: LG is identical to LOG10 like LN being identical to LOGe and LB to LOG2. Never let any mathematician catch you with a naked LOG in your text!)
If you're coming from an ANSI/ISO BASIC world, it's even more confusing. In standard BASIC, LOG is LOGe, LOG2 is LB and LOG10 is LG. In many BASICs, LN is LOGe and there is no other base.
Tom L

Some people call me inept but I'm as ept as anybody!
DM10L SN: 059/100
DM41X SN: 00023 (Beta)
DM41X SN: 00506 (Shipping)
DM42 SN: 00025 (Beta)
DM42 SN: 00221 (Shipping)
Thomas Okken
Posts: 949
Joined: Tue May 02, 2017 5:48 pm
Location: United States → Netherlands
Contact:

### Re: LOG bases

jneven wrote:
Sat Mar 20, 2021 12:39 pm
I did a small test with 5000 times LOG(X)/LOG(B) against LN(X)/LN(B). With LOG it was 17.6 seconds and with LN it was 18.05 seconds. Wondering why, I did the test without the division. There the LN version was 14.2 seconds and the LOG version 14.85 seconds. So, Thomas, the faster division compensates for the slower LOG and makes the LOG version slightly faster .
This is my test case:

Code: Select all

00 { 44-Byte Prgm }
01▸LBL "LTEST"
02 0.1
03 SEED
04 TIME
05 STO 00
06 1ᴇ6
07 STO 01
08▸LBL 00
09 RAN
10 LN
11 RAN
12 LN
13 ÷
14 DSE 01
15 GTO 00
16 TIME
17 RCL 00
18 HMS-
19 1ᴇ4
20 ×
21 END
It took 7.56 seconds with LN on lines 10 and 12, and 7.78 seconds with LOG, running on an Intel Mac.
Not saying any tests that disagree with that result are wrong! It may just be a bit more complicated than a simple "LN is faster" vs. "LOG is faster." More investigation needed.
toml_12953 wrote:
Sat Mar 20, 2021 1:05 pm
Walter wrote:
Sat Mar 20, 2021 11:13 am
(Nitpicky remark: LG is identical to LOG10 like LN being identical to LOGe and LB to LOG2. Never let any mathematician catch you with a naked LOG in your text!)
If you're coming from an ANSI/ISO BASIC world, it's even more confusing. In standard BASIC, LOG is LOGe, LOG2 is LB and LOG10 is LG. In many BASICs, LN is LOGe and there is no other base.
In C and related programming languages, log() is natural (base e) and log10() is base 10. Also, in older mathematics texts in particular, "log" usually means natural. Except, I suppose, when you're looking at really old texts, because the first logarithm to be studied was the base-10 one, because of its obvious relation to the number of digits in its argument.

The "natural" logarithm is called "natural" because its inverse, e^x, is the only exponential that has the nice property of being its own derivative. If you use the base-10 logarithm in analytic derivations, you tend to get annoying factors of ln(10) cropping up.
jneven
Posts: 9
Joined: Sat Jan 23, 2021 6:32 pm
Location: Belgium

### Re: LOG bases

Thomas Okken wrote:
Sat Mar 20, 2021 1:53 pm
jneven wrote:
Sat Mar 20, 2021 12:39 pm
I did a small test with 5000 times LOG(X)/LOG(B) against LN(X)/LN(B). With LOG it was 17.6 seconds and with LN it was 18.05 seconds. Wondering why, I did the test without the division. There the LN version was 14.2 seconds and the LOG version 14.85 seconds. So, Thomas, the faster division compensates for the slower LOG and makes the LOG version slightly faster .
This is my test case:

Code: Select all

00 { 44-Byte Prgm }
01▸LBL "LTEST"
02 0.1
03 SEED
04 TIME
05 STO 00
06 1ᴇ6
07 STO 01
08▸LBL 00
09 RAN
10 LN
11 RAN
12 LN
13 ÷
14 DSE 01
15 GTO 00
16 TIME
17 RCL 00
18 HMS-
19 1ᴇ4
20 ×
21 END
It took 7.56 seconds with LN on lines 10 and 12, and 7.78 seconds with LOG, running on an Intel Mac.
Not saying any tests that disagree with that result are wrong! It may just be a bit more complicated than a simple "LN is faster" vs. "LOG is faster." More investigation needed.
Your test-code is better, Thomas! I was using fixed values to take LOG/LN from. So, I was probably favorizing the LOG10-function. Thanks for your reaction and code.
ijabbott
Posts: 213
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

### Re: LOG bases

Walter wrote:
Sat Mar 20, 2021 11:13 am
(Nitpicky remark: LG is identical to LOG10 like LN being identical to LOGe and LB to LOG2. Never let any mathematician catch you with a naked LOG in your text!)
I think pure mathematicians tend to assume $$\log$$ means $$\log_e$$ because they don't have a lot of use for $$\log_{10}$$.
invariant
Posts: 9
Joined: Fri Apr 02, 2021 8:01 am

### Re: LOG bases

ijabbott wrote:
Tue Mar 23, 2021 10:12 pm
Walter wrote:
Sat Mar 20, 2021 11:13 am
(Nitpicky remark: LG is identical to LOG10 like LN being identical to LOGe and LB to LOG2. Never let any mathematician catch you with a naked LOG in your text!)
I think pure mathematicians tend to assume $$\log$$ means $$\log_e$$ because they don't have a lot of use for $$\log_{10}$$.
Yes. In fact, I think Log, with a capital L is widely understood to be the natural logarithm.
ijabbott
Posts: 213
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

### Re: LOG bases

invariant wrote:
Sat Apr 10, 2021 5:33 am
ijabbott wrote:
Tue Mar 23, 2021 10:12 pm
Walter wrote:
Sat Mar 20, 2021 11:13 am
(Nitpicky remark: LG is identical to LOG10 like LN being identical to LOGe and LB to LOG2. Never let any mathematician catch you with a naked LOG in your text!)
I think pure mathematicians tend to assume $$\log$$ means $$\log_e$$ because they don't have a lot of use for $$\log_{10}$$.
Yes. In fact, I think Log, with a capital L is widely understood to be the natural logarithm.
FWIW, 'Log' has also been used to denote the base 10 logarithm.

ISO-80000-2 recommends 'ln' for base e logarithm, 'lg' for base 10 logarithm, and 'lb' for base 2 logarithm. That is what the WP 34S uses, but in all caps.

Here are (some of) the meanings that have been commonly associated with the different notations:
• lb - base 2 logarithm
• ld - base 2 logarithm
• lg - base 10 logarithm, base 2 logarithm
• ln - base e logarithm
• log - base 10 logarithm, base e logarithm, base 2 logarithm, (unspecified base) logarithm
• Log - base 10 logarithm, base e complex logarithm (multi-valued relation)
Walter
Posts: 1972
Joined: Tue May 02, 2017 11:13 am
Location: Close to FRA, Germany

### Re: LOG bases

ijabbott wrote:
Sat Apr 10, 2021 2:26 pm
ISO-80000-2 recommends 'ln' for base e logarithm, 'lg' for base 10 logarithm, and 'lb' for base 2 logarithm. That is what the WP 34S uses, but in all caps.
Also we are adaptive: The WP 43S uses ln, lg, and lb as ISO 80000-2 recommends for good reason.
DM42 SN: 00041 β
WP 43S running on this device

HP-35, HP-45, ..., HP-35S; WP 34S & WP 31S for obvious reasons; DM16L
invariant
Posts: 9
Joined: Fri Apr 02, 2021 8:01 am

### Re: LOG bases

It does seem wise to avoid log / Log given the possible ambiguities indeed!