Post Reply 
(HP65) Factorial and Gamma Function
10-21-2017, 08:01 PM
Post: #3
RE: (HP65) Factorial and Gamma Function
(10-21-2017 01:21 PM)Dieter Wrote:  What can you say about this approximation's accuracy? It looks good for large arguments but less so for small x, e.g. x=1 results in 0,9995. If you omit the first constant –571/2488320 the average accuracy actually seems to increase.

As already mentioned, the error is larger for small arguments and smaller for large ones. With a little bit of tweaking the coefficients this can be changed to a more evenly distributed error. And finally there is the shift-and-divide method: the approximation is only used for sufficiently large x, say x>6. For smaller x, e.g. 4.25, the approximation is calculated for 6.25 and finally the result divided by (5.25*6.25).

Here is a quick and dirty version of this idea, with modified coefficients:

Code:
LBL A
8
EEX
4
1/x
CHS
STO 1
.
0
0
2
6
9
6
CHS
STO 2
2
8
8
1/x
STO 3
1
2
1/x
STO 4
CLX
RTN
LBL E
6
STO 0
ST0/0
X<>Y
LBL 1
x>y?
GTO 2
1
+
STO*0
GTO 1
LBL 2
STO 5
2
*
PI
*
SQRT
RCL 5
RCL 5
2
/
Y^X
STO 6
*
RCL 5
e^x
/
STO*6
RCL 1
RCL 5
/
RCL 2
+
RCL 5
/
RCL 3
+
RCL 5
/
RCL 4
+
RCL 5
/
1
+
RCL 0
/
RCL 6
*
RTN

If evaluated exactly (!) the largest error should be about 1...2 units in the 9th significant digit. Due to the numeric limitations of a 10-digit calculator the error can and will be slightly higher here and there.

The result for x=4,25 now is 35,21161186. The true result is ...1185.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(HP65) Factorial and Gamma Function - Gamo - 10-21-2017, 08:32 AM
RE: (HP65) Factorial and Gamma Function - Dieter - 10-21-2017 08:01 PM



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