The upper left screen shows how the function Poi() was defined. One
below shows the calculation of Poi(300, 200). At first it is
calculated symbolically and then the result is converted to floating
point number. In this case the result is correct. My TI-89 gives the
same result (two screenshots at right).
When I try to calculate the same function using floating point numbers
as input (lower left screen) I get significantly different result.
What is the problem or what am I doing incorrectly?
And one more question. When working in ALG mode with symbolic
expressions, is it there any way to get them simplified upon every
press of ENTER like TI-89 does? For example I enter:
X+5
then
ANS(1)^2-1
and I get
(X+5)^2-1
If I want to simplify it, I have to select it with arrows and press
ENTER again. How can I get it simplified when I enter ANS(1)^2-1
without pressing ENTER once more?
In the RPN mode, all you have to do is press the EVAL key.
You might try that in ALG mode and see what happens.
Floating point numbers on the HP can't go higher than 10^499. In
addition, they are limited to 12 significant digits. You're computing
Poi(y,k) = e^(-y)*y^k/k!. So Poi(300,200) = e^-300 * 300^200/200!.
300^200 and 200! are far beyond the limits floating point numbers.
This is a very old problem with computers. The trick is to change the
order of evaluation. Instead of evaluating 300^200 and dividing by
200!, you need to evaluate (300/200)*(300/199)*(300/198)*...(300/2)*
(300/1). Sorry, I don't have the time right now to figure out exactly
how to do this.
It's too bad that HP doesn't supply a LNFACT() function where LNFACT
(x) = ln(x!). This is pretty easy to compute from ln(gamma(x)) which
can be computed directly. If you had LNFACT() then ln(POI(y,k)) = -y
+k*ln(y)-LNFACT(k), which are all reasonably sized numbers that can be
represented in the calculator. So POI(y,k) = e^(-y+k*ln(y)-LNFACT(k))
Dave
I have been saying for YEARS that the HP calculators need a lngamma
function.
An easy way to do it yourself in user RPL would be to use ln(gamma(x))
for 0 < x < 100 or so,
and use Stirlings apporximation for larger x.
You can use Lanczos' approximation for all complex values with
positive imaginary part,
but it is more complicated.
Martin Cohen
Visit http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv018.cgi?read=132639,
then scroll down to message #6. I posted a LogGamma and LambertW for
the 50g. They are written in C with a library front end. The memory
used in the 50g is on the order of bytes. The C programs will need to
be installed on the SD card. Complex values supported.
There is no special.zip in http://sense.net/~egan/hpgcc/misc/ !
Yikes! Thanks. Fixed now. I broke the link with some house cleaning.
Thank you for HPGCC tutorial LambertW and LogGamma :-) .
Best regards,
Simone.