Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Howto do log base2 on HP48G

2,455 views
Skip to first unread message

Laith Haddadin

unread,
Dec 10, 1997, 3:00:00 AM12/10/97
to

How do I do: floor(log base2 8000) for instance. I only see the log
base10 key. Is there a way to change the base of the log function on an
HP48G?

Thanks,
Laith E.H.


Jonathan M. Katz

unread,
Dec 10, 1997, 3:00:00 AM12/10/97
to

If you look in an algebra textbook, you'll find the following
property of logarithms:

log_a(x) = ln(x)/ln(a)

where log_a(x) is "Log base a of x" (in your case "Log base 2
of 8000"), and ln is (of course) natural logarithm, log base e.

So your answer will be 12. You can verify this by EVALuating
the following expression:

'FLOOR(LN(8000)/LN(2))'

Hope this helps,

katz
--
In order to e-mail me a reply to this message, you will have
to edit the address shown in the header. You know what to do.

BABarracus

unread,
Dec 10, 1997, 3:00:00 AM12/10/97
to

>How do I do: floor(log base2 8000) for instance. I only see the log
>base10 key. Is there a way to change the base of the log function on an
>HP48G?
>
>Thanks,
> Laith E.H.

log base x y=logy/logx
base of logs on right can be anything, but since you just happen to have the
base 10 key, I suggest it

Galen

Joel Ebel

unread,
Dec 10, 1997, 3:00:00 AM12/10/97
to

I wrote a program to do that:
<<log swap log />>
enter the # and base and run the program. You get the result. :)

Jarno Peschier

unread,
Dec 12, 1997, 3:00:00 AM12/12/97
to

Laith Haddadin <gt8...@prism.gatech.edu> wrote the following:

>How do I do: floor(log base2 8000) for instance. I only see the log
>base10 key. Is there a way to change the base of the log function on an
>HP48G?

No, but you don't need to. In fact, strictly speaking you don't need
the LOG function if you have the LN function (and vice versa, if you
have or know the value of e as well).

If you know anything about logarithms, you also know the following
equality: a^log(x) = b^log(x)/b^log(a). So, in order to calculate
2^log(8000) you can use either log(8000)/log(2) or ln(8000)/ln(2).
That's just basic mathematical knowledge. A scientific calculator is a
tool, not a magical device...

Oh, by the way. If you want to use the 2^log() function (also know as
lg() to computer scientists) often, you can put the following program
in your HP48's home directory under the name of 'LG' and then simply
use LG in algabraic expressions as you would LOG or LN:

<< -> x 'LN(x)/LN(2)' >>


Jarno Peschier, computer science student, Utrecht University
mailto:jpes...@cs.ruu.nl http://jarno.home.ml.org/
____________________________________________________________
'avwI' nejDI' narghta'bogh qama' reH 'avwI' Sambej

Blake Garretson

unread,
Dec 13, 1997, 3:00:00 AM12/13/97
to

Laith Haddadin <gt8...@prism.gatech.edu> wrote:
>How do I do: floor(log base2 8000) for instance. I only see the log
>base10 key. Is there a way to change the base of the log function on an
>HP48G?
>
There's also a program called LOGB that takes two arguments from the
stack and returns the answer. It is slightly better than
log_x y = log y / log x
because the program uses full internal precision so it doesn't
compound the rounding error.


-----------------------------------------------------
Blake T. Garretson
bgar...@eng.utoledo.edu
http://eng.utoledo.edu/~bgarrets
-----------------------------------------------------

Joseph K. Horn

unread,
Dec 13, 1997, 3:00:00 AM12/13/97
to

In article <348F075A...@prism.gatech.edu>,

Laith Haddadin <gt8...@prism.gatech.edu> wrote:
>
> How do I do: floor(log base2 8000) for instance. I only see the log
> base10 key. Is there a way to change the base of the log function on an
> HP48G?
>
> Thanks,
> Laith E.H.

Several readers have replied that log base 2 of x = ln(x)/ln(2) or
log(x)/log(2). Although this is mathematically correct, it can
result in roundoff errors.

For example, check out log base 2 of 2^34:

LN(2^34)/ LN(2) --> 33.9999999999
LOG(2^34)/LOG(2) --> 34.0000000001

Sometimes LOG is wrong and LN correct; other times vice versa.
Sometimes both are right; sometimes both are wrong. When both
are wrong, sometimes they straddle the correct answer (as in
the example above), and sometimes they are both less than (or
greater than) the correct answer. It's not predictable.

If 12-digit accuracy is not required, use the log/log method.
If full machine accuracy is required, however, then use LOGB
by Paul Dale, available on Goodies Disk #5. It merely does
log/log in System RPL using long reals. It gets the correct
answer for log base 2 of 2^34.

-Joe-

-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet

John H Meyers

unread,
Dec 15, 1997, 3:00:00 AM12/15/97
to

Excerpt of a post from 1997/02/07 "Multi-precision, extended reals,etc.":

The following program LOGX(Y,X) takes log(Y) [level-2], base X [level-1],
using extended precision intermediate computations for greatest accuracy
(just as do all internal HP48 functions); if the arguments are not both
real numbers, however, then a more conventional approach is taken:

%%HP: T(3); @ include this line only for Kermit transfer PC -> HP48
@ Use either with stack args or as algebraic function of 2 args
\<< \-> y x \<< x y IF OVER TYPE OVER TYPE OR THEN LN SWAP LN /
ELSE #2B45Ch SYSEVAL #2AB5Bh SYSEVAL SWAP #2AB5Bh SYSEVAL
#2A9E8h SYSEVAL #2A5B0h SYSEVAL END \>> \>>
@ Checksum #8B08h, 158 bytes (on stack)

SysRPL (main computation): 2%>%% %%LN SWAP %%LN %%/ %%>%
[the first word converts 2 reals at once, the rest are "obvious"]

Warning: SYSEVAL's emit hazardous radiation, which may nuke all of
your memory if they are either entered or used incorrectly;
verify checksum before using.

Some errors (e.g. negative input) will leave not only a "Long Real"
on the stack, but also an "External" (PTR 0), which you should discard.

LOGB (GD#5) takes arguments in the opposite order, and is not structured
as a function usable in algebraics, but it behaves more nicely upon errors.

See also LONGAGO.DOC from the same GD#5.

-----------------------------------------------------------
With best wishes from: John H Meyers <jhme...@mum.edu>

Vach

unread,
Dec 26, 1997, 3:00:00 AM12/26/97
to

On Fri, 12 Dec 1997 17:56:00 GMT, jpes...@cs.ruu.nl (Jarno Peschier)
wrote:

>No, but you don't need to. In fact, strictly speaking you don't need
>the LOG function if you have the LN function (and vice versa, if you
>have or know the value of e as well).
>
>If you know anything about logarithms, you also know the following
>equality: a^log(x) = b^log(x)/b^log(a). So, in order to calculate
>2^log(8000) you can use either log(8000)/log(2) or ln(8000)/ln(2).
>That's just basic mathematical knowledge. A scientific calculator is a
>tool, not a magical device...
>
>Oh, by the way. If you want to use the 2^log() function (also know as
>lg() to computer scientists) often, you can put the following program
>in your HP48's home directory under the name of 'LG' and then simply
>use LG in algabraic expressions as you would LOG or LN:
>
><< -> x 'LN(x)/LN(2)' >>

Hi.

Could you help me a little.
When you white a^log(x) do you mean a log with base of a or a with
potential of log(x)...

You whote a: " a^log(x) = b^log(x)/b^log(a) " could you look in my
attachment and tell me is it the one by 1. or one by 2.

Thanks in advance for your answer.

***************************************************

If you wan't to e-mail me delete "_REMOVE_THIS_" from my e-mail address

***************************************************

Spam Bait

Chairman Reed Hundt: rhu...@fcc.gov
Commissioner James Quello: jqu...@fcc.gov
Commissioner Susan Ness: sn...@fcc.gov
Commissioner Rachelle Chong: rch...@fcc.gov
More SPAM Bait: ro...@mailloop.com,jo...@mailloop.com,jor...@earthlink.net
ma...@SALLYNET.COM , iq2...@usa.net , rem...@hotmail.com
fr...@ca.udec.edu

Vach

unread,
Dec 26, 1997, 3:00:00 AM12/26/97
to

begin 644 log.gif
<encoded_portion_removed>
end

Vach

unread,
Dec 26, 1997, 3:00:00 AM12/26/97
to

On Sat, 13 Dec 1997 16:29:09 GMT, bgar...@top.eng.utoledo.edu (Blake
Garretson) wrote:

>There's also a program called LOGB that takes two arguments from the
>stack and returns the answer. It is slightly better than
>log_x y = log y / log x
>because the program uses full internal precision so it doesn't
>compound the rounding error.

Would you be so kind and send me the mentioned program, or at least
tell m ewhere can I find it.

Thanks in advance.

0 new messages