HP41: accuracy of 13digit routines

09042015, 07:36 PM
(This post was last modified: 09042015 09:57 PM by Dieter.)
Post: #14




RE: HP41: accuracy of 13digit routines
(09042015 12:07 PM)Ángel Martin Wrote: I finally got around to doing the changes in the GAMMA code, using the coefficients you came up with. See the attached MOD file with the modified verison of the function already compiled. Ah, thank you very much. :) (09042015 12:07 PM)Ángel Martin Wrote: Indeed the results are very much the same, with the exception of points around x=1, see the comparison table that also has the WolframAlpha colum as 'exact' answers: Hm... for values below 1 the accuracy is not what I would have expected. But I think there is a simple reason for this. See below. (09042015 12:07 PM)Ángel Martin Wrote: (as usual I can't get the table format right... That's easy. Text bracketed by codetags is formatted with a fixed font. However, the message editor is always set to its standard proportional font... #) So you simply have to use another editor (notepad.exe will do), format your code section there and copy/paste it back to the message editor. At least that's the way I do it. This way you get... Code: x Sandmath Dieter Exact (10 dig.) (12 dig.) (note: your table listed a quite inaccurate Sandmath result for x=–0.5 while actually it is dead on. The new table lists the correct result). (09042015 12:07 PM)Ángel Martin Wrote: So all in all it's better  with a caveat in that region mentioned before. No idea why would that be the case, right? Well, actually I think I know what causes the problem... #) The original coefficient set was optimized for the factorial function with 0 ≤ x ≤ 70. For the Gamma function this translates to 1 ≤ x ≤ 71. So arguments less than 1 will cause substantially larger errors than those within the optimized domain. That's why it performs so poorly between x=0 and 1, for instance at x=0.1. On the other hand Gamma(1.1)/0.1 yields a correct result, as well as Gamma(1.5)/0.5 which now should return 1.772453851. I assume the reflection formula is used for x < 0.5 (where x = 1–x). So we actually need a new coefficient set that is optimized for 0.5 ≤ x ≤ 71. Sorry, I just overlooked this point. I'll see what I can come up with. This means some more hours with Excel and Free 42... #) Maybe you can do some more tests for x>1 or x<0 and compare the results with Sandmath's. The error maxima are near x=1.245, 2.395, 5.15, 12.25 and 34. Update: I now have set up a new approximation for 0.5 ≤ x ≤ 71 with a relative error of approx. 3 E–11. Dieter 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)