Post Reply 
[VA] SRC #017 - April 1st, 2024 Spring Special
04-09-2024, 05:19 PM (This post was last modified: 04-10-2024 01:50 AM by Gerson W. Barbosa.)
Post: #13
RE: [VA] SRC #017 - April 1st, 2024 Spring Special
(04-07-2024 11:10 PM)Gerson W. Barbosa Wrote:  By using the constant 9.89055995288 we can get up to 7 correct digits of γ on the HP-42S and up to 23 on Free42:

00 { 38-Byte Prgm }
01▸LBL "E_M"
02 RCL ST X
03 +/-
04 10↑X
05 GAMMA
06 FP
07 X<>Y
08 NOT
09 10↑X
10 9.89055995288
11 ×
12 -
13 +/-
14 1
15 +
16 END

4 XEQ "E_M" ->

0.5772156756

11 XEQ "E_M" ->

0.57721566490153286060651

The constant actually goes like

K = 9.890559953279725553953956515

But there’s a better way to get those extra digits. We only have to use the GAMMA function twice:

00 { 29-Byte Prgm }
01▸LBL "E_M"
02 1
03 -11
04 10↑X
05 GAMMA
06 LASTX
07 R↓
08 FP
09 -
10 R↑
11 +/-
12 GAMMA
13 FP
14 -
15 2
16 ÷
17 END


This will return

0.577215664901532860606565,

good to 22 digits, but nine bytes shorter.

Or we can add a couple of steps and get all 34 digits right, at the cost of another nineteen bites:

17 5.29099175976ᴇ-23
18 -


But then again the following should be more simple and two bytes shorter:

00 { 46-Byte Prgm }
01▸LBL "E_M"
02 5.772156649015328606065120900824024ᴇ-1
03 END


------------------------------------------------------------

Update

If all we want to do is to obtain γ from Γ then this 42-byte Free42 program is better:

00 { 42-Byte Prgm }
01▸LBL "E_M"
02 -11
03 10↑X
04 GAMMA
05 LASTX
06 +/-
07 GAMMA
08 +
09 -2
10 ÷
11 5.29099175976ᴇ-23
12 -
13 END

XEQ "E_M" ->

5.772156649015328606065120900824024E-1
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #017 - April 1st, 2024 Spring Special - Gerson W. Barbosa - 04-09-2024 05:19 PM



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