HP Forums

Full Version: Check on mathematical identity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi All,

Is the following identity correct?

Log(1+x) = x / AGM(1, x)

Log could be either ln(x) or log10(x). AGM is the average-geometric mean function (see here for definition).


If the identity were true then

AGM(1, x) = x/Log(1+x)

Now, if x=1 then

AGM(1, 1) = 1/Log(1+x)

1 = 1/Log(2) --> Log(2) = 1

But either ln(2) or log102 are different than 1. Therefore the identity does not hold.

Why would you guess that was the case?

In any case, the Wikipedia article itself mentions that AGM can be expressed in terms of an elliptic integral, which itself cannot be expressed as an elementary function, so there is no hope of it simplifying to log.

AGM is one method that is used to calculate log to high accuracy.

The 34S used this algorithm for a while.

The 34S also has an AGM function built in.

- Pauli


Yep ... that equation sure works!! I set m to 16 and got very good results.



Edited: 24 Aug 2012, 8:45 a.m.

What algorithm does the WP32S currently use?


What algorithm does the WP32S currently use?

Dunno ;-)

Shammas Polynomials???????????!!!!!!!!!!!!

No idea. I simply don't know a WP32S ;-)

I had to set m much higher to get accurate enough results for single precision. I don't remember exactly what I set it to though.

- Pauli

The comment before the natural logarithm function from the 34S source code is:

/* Natural logarithm.
* Take advantage of the fact that we store our numbers in the form: m * 10^e
* so log(m * 10^e) = log(m) + e * log(10)
* do this so that m is always in the range 0.1 <= m < 2. However if the number
* is already in the range 0.5 .. 1.5, this step is skipped.
* Then use the fact that ln(x^2) = 2 * ln(x) to range reduce the mantissa
* into 1/sqrt(2) <= m < 2.
* Finally, apply the series expansion:
* ln(x) = 2(a+a^3/3+a^5/5+...) where a=(x-1)/(x+1)
* which converges quickly for an argument near unity.

I don't remember making any any other refinements but might have. This is around line 750 of decn.c if you want to look at the actual code.

The native decNumber library uses Newton's method after an initial estimate and this proved very slow. I then switched to the AGM code which was faster but quite a bit less accurate. I later moved to the current code which is both faster again and accurate. Even so, our code for the natural logarithm is on the slow side and a faster method would be appreciated. Unfortunately, I can't justify the use of tables of piecewise polynomial or rational approximations which seem to be the typical way to implement this function.

- Pauli

On the advice of several of you users a couple weeks ago. in response to a query I posed, I purchased An Atlas of Functions, 2nd Edition, by Oldham, Myland, and Spanier. I just began to peruse the book last night (did I say I got a BRAND NEW COPY from Alibris.com for just 99 cents + s&h!!) and within 15 pages came upon a mean I had never heard of...the arithmeticogeometric mean. The text does not go a lot in to detail for the mean. Is this the same mean as the AGM? If so what a major coincidence! I am really enjoying this text. Whomever told me it is "imminently more readable" than other texts was exactly right. Question, my copy came with Equator, the Atlas Function Calculator software on CD. I will probably never need it, but decided to install it anyway. Would not work with my machine (Windows 7 Home Premium 64-bit). Has anyone successfully installed Equator on Windows 7?

Yes, this is the same as the AGM.

I've no ideas about the software CD, I've not yet used it and doubt I ever will.

- Pauli

Hey Pauli, yea, you told me that in an email. Thanks for suggesting the book and being sure I got the right one. It is an amazing reference as well as being a very beautifully done product.

I usually install the software that comes with texts like these, play with them for 1/2, maybe a whole hour, then delete the file and archive the CD. Just bothered me that this one would not install, in spite of being fairly recent (2008 I believe it was?).

Windows 7 is starting to scare me and I don't even have it yet! I still run XP on all my systems and they have been and still are absolutely trouble-free. Still I am ordering a laptop and have no choice but to get it with Win7 already installed. Many friends and business aquaintances have mentioned all sorts of troubles with Win7 so I'm a bit apprehensive about it.

Does Win7 have some (backward) compatibility settings when running programs? 2008 doesn't sound that long ago but, thanks to Moore's Law and Microsoft programmers creating bloated code in the same style as our deficit spending, it's almost ancient history!

Windows 7 has the full complement of Run in Windows XXX Compatibility Modes and, as with the Compatibility function of every Windows edition ever written, NONE of them work. Ever.

That's part of the reason I keep my old machines. I have a DOS/Win 3.1-based 486 system with 5.25"/3.5" floppy drives and a couple of Pentium Win 98 machines. All still work and have come in handy. I recently extracted some old CAD drawings in .dxf from the old DOS machine and was able to import them into very current CAD programs with few problems.

I also have a copy of this book coming so I'll see what happens in XP. I suppose you have checked online for a possible patch or updated version (not that we really need this calc anyway though I suppose)?

Yes, I have completed a fairly thorough google search to no avail. I will keep looking, for a day or two.

I find it works fine, and there is always XP Mode if you have Pro...

In any case, without compatibility mode I wouldn't have been able to program my WP-34s using a serial cable.

How XP-like is it? One big problem my company has had involves Win7 problems with MIDI files and the Audio control panel in general (or should I say the lack thereof). We have firmware updates distributed as MIDI SYSEX files and they work perfectly in XP. Unfortunately they stopped working at all in Win7 (even when using some of the workarounds we've found on the Internet). It's hard to believe all the problems these version changes can cause. I spent almost a year with a brand new Dell and Windows ME trying to get some audio recording software to work. I finally installed Win 2000 and it all worked perfectly. No one could ever explain why and ME was pretty quickly abandoned. Unfortunately I happened to be one of the early adopters (and paid the price for it too!).

Pete, glad the compatibility mode worked for you. I have several, probably thousands, of files laying around here that I would love to use. When they do not run natively on a newer version of Windows, I have NEVER gotten them to work in compatibility mode. That's why, this weekend, with 650GB free space on my HDD, I am installing a dual-boot system with 7 and XP. Quickest way I know to have both.

OK, setting up a dual boot system with 7 and XP is just not worth the effort. Windows 7 Pro upgrade is about 100 bucks. I have two older systems in the house that are XP machines, missing various parts. Now, looks like I'll cobble together one machine from the two. I have tried VMWare before and had it eat a lot of data for dinner, not messing with that crap again. If didn't find 6 or 8 files a week I want to run, that will not run outside XP, I wouldn't bother.