HP Prime emulator: Gamma function « Next Oldest | Next Newest »

 ▼ Stephan Matthys Junior Member Posts: 20 Threads: 4 Joined: Aug 2013 08-21-2013, 02:32 PM I played around with the HP Prime emulator today & also tried the Gamma function. For positive numbers everything seems to be OK, but for negative numbers the Prime emulation gives different results compared to my 15C, 15C LE, 34C, 35s & HP49g+ (which all give the same result, e.g. -5.5! => -0.0600; unfortunately I forgot the result of the Prime emulator & my virtual W7 machine is not up at the moment...) Might there be a problem with the Gamma function of the HP Prime? Or is it only an emulator problem? ▼ Tim Wessman Posting Freak Posts: 1,278 Threads: 44 Joined: Jul 2007 08-21-2013, 02:53 PM Did you look at the help for the function? Graph both Gamma(X) and X! and I think you'll see what is happening. Also compare the graph at http://en.wikipedia.org/wiki/Gamma_function to what you see on the calc. TW Edited: 21 Aug 2013, 2:54 p.m. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-21-2013, 03:03 PM On the HP-49G+ and on the Prime, Gamma and ! are two different functions. From the manual: --------------------------------------- Factorial: Factorial of a positive integer. For non-integers, ! = |-- (x + 1). This calculates the gamma function. ```value! . . . ``` Gamma: Returns the value of the gamma function (|--) for a number a. ```Gamma(a) ``` --------------------------------------- Thus Gamma(-4.5) = (-5.5)! = -0.0600196013005 Gerson. ----- This was meant to Stephan. Somehow it has ended up here. Edited: 21 Aug 2013, 3:05 p.m. ▼ Stephan Matthys Junior Member Posts: 20 Threads: 4 Joined: Aug 2013 08-21-2013, 03:06 PM Thanks, Gerson. Actually I know the difference between ! & Gamma. I just was astonished that my Prime emulator gave me some unexpected result, but as Joe proposed I'll check my settings first. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-21-2013, 10:57 PM You might also want to check your emulator version: ▼ Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-22-2013, 01:39 AM WolframAlpha disagrees with the precedence of - and !: -5.5! = -287.885.... Cheers Thomas Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-22-2013, 01:58 AM Gerson are you sure about -5.5! ? I get this for (-5.5)! with my emulator -5.5! -> -287.885... ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 07:53 AM Gilles and Thomas, I did enter (-5.5)!, but the history showed -5.5! (I hadn't noticed that). Looks like we have another bug here: Cheers, Gerson. Stephan Matthys Junior Member Posts: 20 Threads: 4 Joined: Aug 2013 08-22-2013, 02:01 AM I checked the thing again this morning & got the incorrect results again: :-o Edit: It seems I have problems with the images (if it's not only our proxy server) ... The values are: Gamma(-4.5) = -.245736133286 (-5.5)! = -.245736133286 However, after resetting the calculator it shows the correct result: Thus it might have been some weird settings preventing the calculator to return the correct results: Gamma(-4.5) = -.0600196013005 (-5.5)! = -.0600196013005 The version of my emulator is: Version 2013 8 5. Rev: 4980 The emulator tells me that there's no newer version available. I apologise for all inconveniences... Thanks for your support! Edited: 22 Aug 2013, 2:16 a.m. ▼ Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-22-2013, 02:56 AM [img:http://img96.imageshack.us/img96/1623/yaui.png] [img:http://img580.imageshack.us/img580/8314/dkpr.png] [img:http://img839.imageshack.us/img839/6941/nv0h.png] Not a problem with a proxy but with markup. And I used the direct URL. Cheers Thomas Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-22-2013, 03:02 AM I got it ! CAS mode Set <\ in degree (-5.5)! = -.245736133286 Rev 4980 ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 08:03 AM Good find! This means the formula involving sine is being used for negative arguments. The bug persists on Rev. 5106. ▼ Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-22-2013, 10:20 AM Quote: This means the formula involving sine is being used for negative arguments.  Quote: The values are: Gamma(-4.5) = -.245736133286 Gerson, I think you're correct! But then why is -4.5 used instead of 5.5 in sin? Cheers Thomas Edited: 22 Aug 2013, 10:23 a.m. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 02:01 PM Perhaps they're doing ```(-z)!(z - 1)! = pi/(sin(pi*z)) ``` and letting ```z = -4.5 ``` Thus, ```Gamma(-4.5) = (-5.5)! = pi/(sin(-pi*4.5)*4.5!) = -0.0600196013005 ``` Considering the argument has been unduly converted into degrees, we convert it back to radians, that is, ```z = -4.5*pi/180 ``` and we get the same result the Prime is giving, -0.245736133286, which of course is completely wrong, as you know. Cheers, Gerson. Edited to fix a typo. Edited: 22 Aug 2013, 2:53 p.m. ▼ Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-22-2013, 03:04 PM Oh, now I see:  Thanks for pointing that out! Best regards Thomas ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 11:59 PM Actually I only intended to write it in an easier-to-remember and less prone to confusion form:  Best regards, Gerson. ▼ Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-23-2013, 02:01 AM This formula reminds me of Valentin's HP-15C Mini-challenge. Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-22-2013, 11:17 AM I tested with XCAS and same problem... Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 08:14 AM Quote: However, after resetting the calculator it shows the correct result: Thus it might have been some weird settings preventing the calculator to return the correct results: Gamma(-4.5) = -.0600196013005 (-5.5)! = -.0600196013005 Not your fault, but HP's. They've forgotten to check the user's angle mode setting when evaluating Gamma . See Gilles's post below. You've indeed found a new bug. Thanks for reporting! Regards, Gerson. ▼ Stephan Matthys Junior Member Posts: 20 Threads: 4 Joined: Aug 2013 08-22-2013, 11:23 AM You're welcome. Actually it was by mistake... ;-) Does anyone know if the bug also occurs on the real Prime or just in the emulator? Edited: 22 Aug 2013, 11:24 a.m. Miguel Toro Member Posts: 239 Threads: 55 Joined: Sep 2006 08-22-2013, 02:22 PM Hi, So, CAS mode does not show the expression the way you entered (CAS mode, Radians): What is the difference between these two ? Well, I copy the first one : Then press [Enter] key: Then, I copy the second one : And there you have it. Of course, pressing [Enter] key gives: ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 08-22-2013, 04:45 PM So they look alike, but are actually different :-)Perhaps more difficult to fix than the other bug, but I think HP should address this one as well. Otherwise screen prints won't be a reliable information anymore. Regards, Gerson. Joe Horn Member Posts: 153 Threads: 7 Joined: Jun 2008 08-21-2013, 02:58 PM If it's a bug, it must involve a setting of some kind, because after Calculator Clear on the emulator, all four of the following return the same correct result (-.0600196013005) both in Home and in CAS: (-5.5)! (using the [-] key) (-5.5)! (using the [+/-] key) Gamma(-4.5) (using the [-] key) Gamma(-4.5) (using the [+/-] key) If you see the bug again, please let us know what your non-default settings are. Thanks! -Joe- ▼ Stephan Matthys Junior Member Posts: 20 Threads: 4 Joined: Aug 2013 08-21-2013, 03:02 PM Thanks, Joe. I'll have to check that tomorrow. Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-22-2013, 03:07 AM Hi Joe The bug is in CAS mode and ° setting : Set angle in Radian CAS mode (-5.5)! -> -.6... now set angle in ° (always CAS mode) (-5.5)! -> -.2457... (Rev 4980) Edited: 22 Aug 2013, 3:14 a.m. ▼ Marcus von Cube, Germany Posting Freak Posts: 3,283 Threads: 104 Joined: Jul 2005 08-22-2013, 03:46 AM The setting (Degree or radian) affects both environments (goto settings in CAS or Home and see they are the same). The error only occurs from the CAS screen, not from the Home screen. peacecalc Member Posts: 97 Threads: 9 Joined: Nov 2011 08-22-2013, 04:08 AM Hello prime researchers, the gamma function is normally defined for complex numbers except the negative integers. Maybe there is connection between the DEG and RAD mode and the inconsistent results in CAS mode? Greeting peacecalc Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 08-22-2013, 04:32 AM Quote: More important to get things right, with a smaller subset of functions that are fully tested and well documented, before starting the "lets lump in everyone's favorite function" game... Couldn't agree more. Cheers Thomas Namir Posting Freak Posts: 2,247 Threads: 200 Joined: Jun 2005 08-21-2013, 04:52 PM I compared a few negative values (-5.5, -4.5, -3.5, -2.25, -2.45, and -22.45) for the Gamma function using the emulator AND using Wolfram Alpha. I did not see any difference in the results. Namir Edited: 21 Aug 2013, 4:53 p.m.

 Possibly Related Threads... Thread Author Replies Views Last Post Prime Emulator Connection Problem John Colvin 3 1,338 12-14-2013, 11:00 PM Last Post: Han HP Prime Emulator download John Colvin 2 1,072 12-14-2013, 05:54 PM Last Post: John Colvin HP50g: Writing a function that returns a function Chris de Castro 2 1,087 12-10-2013, 06:49 PM Last Post: Han IFERR function on HP Prime Mic 2 1,011 12-02-2013, 01:33 AM Last Post: cyrille de Brébisson HP Prime: Dirichlet's eta function recognized but not numerically evaluated Helge Gabert 0 647 11-16-2013, 03:41 PM Last Post: Helge Gabert Possible bug with sqrt function in the HP prime Michael de Estrada 6 1,307 11-15-2013, 12:49 PM Last Post: Michael de Estrada HP-41 MCODE: The Last Function - at last! Ángel Martin 0 596 11-08-2013, 05:11 AM Last Post: Ángel Martin [Prime] any ideas for a undo function? Stefan Dröge (Germany) 8 1,601 11-04-2013, 04:37 PM Last Post: Damien HP Prime 'where' function bluesun08 11 2,038 10-29-2013, 06:56 PM Last Post: Joe Horn HP Prime - Defining a function bluesun08 5 1,228 10-23-2013, 02:43 PM Last Post: Han

Forum Jump: