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

How do HP cals calculate the factorial function???

58 views
Skip to first unread message

Zeno

unread,
Oct 26, 2006, 8:18:32 PM10/26/06
to
I know of course what the factorial function is, ie 5! equals 5*4*3*2*1
and so forth, but i was woondering if there is a so called "shortcut"
algorithm that calcs can use to computer the factorial function. i am
referring to computing the whole exact answer, not a a aproximation
using expoential notation. Just curious.

Arnaud Amiel

unread,
Oct 27, 2006, 3:41:57 AM10/27/06
to
Actually the hp calculators use a slightly modified Gamma function.
See there:
http://en.wikipedia.org/wiki/Gamma_function

This is why the hp will calculate 6.25! and give a result

You may also want to check there:
http://www.rskey.org/detail.asp?manufacturer=Hewlett-Packard&model=HP-48SX

For an implementation of the gamma function

Arnaud

Veli-Pekka Nousiainen

unread,
Oct 27, 2006, 5:45:53 AM10/27/06
to

Exact, like 100!
You want to know the algorithm?
There is no shortcut for exact answers


Zeno

unread,
Oct 27, 2006, 1:46:36 PM10/27/06
to
In article <ntk0h.38728$ij5....@reader1.news.jippii.net>, Veli-Pekka
Nousiainen <DROP...@dlc.fi> wrote:

That's what i figured...I know about the shortcut for approximate
answers, there ar some nice java apps online that use it for factorials
for very high numbers resulting in instant results.

pgme...@yahoo.com

unread,
Oct 27, 2006, 4:22:21 PM10/27/06
to

pgme...@yahoo.com

unread,
Oct 27, 2006, 4:29:47 PM10/27/06
to

There IS a sort of shortcut that has wide application actually. It is
called 'memo-ization' or caching.
If you want to calc 100! and you have not calculated any factorial
before, then there is no shortcut.
But if you had previously calculated 99! and you wanted 100! there is
an obvious shortcut provided you make it a policy to save (cache) the
value of 99! (Which means you have saved 98! etc.)
The cost is trivial (a couple of hundred memory locations) on large
machines, and the benefits enormous. Not sure if it is viable as a
strategy for calculators, but it is certainly viable for calculator
based programs.
Another example is if you are doing date calculations. Since most dates
of interest are within the last month, you can cache the 'epoch' value
of the beginning of the month, and then do all future date calcs as
offset from there.
and so on.
As I said, the technique has wide application.

pgmer6809

Jean-Yves Avenard

unread,
Oct 28, 2006, 8:39:26 PM10/28/06
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi


Arnaud Amiel wrote:
> Actually the hp calculators use a slightly modified Gamma function.
> See there:
> http://en.wikipedia.org/wiki/Gamma_function
>
> This is why the hp will calculate 6.25! and give a result

This is only true for fractional number..

For integers, there's no much choice other than doing it the long way...
JY
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFQ/g+OgesMt/k2XMRAm21AJ9XtkklXQo/7K02oxOSpLTWmR4ZKACfSWQu
gAqgVptQX8vQSPprkk04LGg=
=aYmS
-----END PGP SIGNATURE-----

FX-502P Geek

unread,
Oct 29, 2006, 4:19:32 PM10/29/06
to
I suspect, but don't know, that calculators that just calculate integer
values use look-up tables. Older calculators took noticeably longer to
calculate the higher valued factorials. I remember that the standard
speed test at my school in the early 80s was to test the speed of 69! -
the largest value that fits under 1e100. However in the mid-80s I got a
solar powered Sharp EL545 which was clearly slower even doing trig than
the battery powered Casios that I had. The Sharp beat them all on the
factorial however taking the same time for them all. With only 70 valid
input values a look-up table could be valid option. If your maximum
value allowed is just <1e500 then your table only needs 254 values.

yours,
Peter Martin.

Steen Schmidt

unread,
Oct 30, 2006, 12:53:09 AM10/30/06
to
FX-502P Geek wrote:

> I suspect, but don't know, that calculators that just calculate
> integer values use look-up tables.

I doubt that. It's very fast doing 69 multiplications.

Regards
Steen

Veli-Pekka Nousiainen

unread,
Oct 30, 2006, 6:09:24 PM10/30/06
to

Right - but with infinite integers of the 49G/49g+/50G
one would need quite a big lookup table
;-)


Joel Kolstad

unread,
Oct 30, 2006, 7:39:37 PM10/30/06
to
"FX-502P Geek" <use_...@www.fx502p.pwp.blueyonder.co.uk> wrote in message
news:EV81h.83206$lT5....@fe2.news.blueyonder.co.uk...

> pgme...@yahoo.com wrote:
> I remember that the standard speed test at my school in the early 80s was to
> test the speed of 69! - the largest value that fits under 1e100.

Indeed, I remember doing that as well.

In particular I recall that my Casio 4000P was exactly twice as slow as my
brother's Casio 7000G -- the first widely-known graphing calculator.

TI calculators often seemed quite slow compared to Casios and Sharps...

Veli-Pekka Nousiainen

unread,
Nov 1, 2006, 11:08:00 AM11/1/06
to
pgme...@yahoo.com wrote:
X

> There IS a sort of shortcut that has wide application actually. It is
> called 'memo-ization' or caching.
> If you want to calc 100! and you have not calculated any factorial
> before, then there is no shortcut.
> But if you had previously calculated 99! and you wanted 100! there is
> an obvious shortcut provided you make it a policy to save (cache) the
> value of 99! (Which means you have saved 98! etc.)
> The cost is trivial (a couple of hundred memory locations) on large
> machines, and the benefits enormous. Not sure if it is viable as a
> strategy for calculators, but it is certainly viable for calculator
> based programs.
> Another example is if you are doing date calculations. Since most
> dates of interest are within the last month, you can cache the
> 'epoch' value of the beginning of the month, and then do all future
> date calcs as offset from there.
> and so on.
> As I said, the technique has wide application.

Except that the HP-50G (49g+)
is extremely fast in such calculations
but the amount of expensive Static CMOS RAM is limited
(also due to Saturn CPU addressing limitations)


0 new messages