### Q function of HP-21S unveiled

Posted:

**Thu Jul 09, 2020 1:53 pm**With the trace feature of Emu42 I was able to find out the two procedures of the HP-21S to compute Q(z) -- one of them was new to me.

Here an HP-42S program using the same algorithms.

Note: in contrast to the HP-32E the HP-21S calculates "the upper tail" of the Q function.

The formulas? If you are truly interested take a closer look to this user code routine, it is much simpler than analysing some firmware trace.

M.

Edit: replaced lines 13 1/x and 14 * by 13 / only. It was a holdover from the HP-21S, which uses the constant @03966: #0398942280401432.

Here an HP-42S program using the same algorithms.

- Code: Select all
`00 { 131-Byte Prgm }`

01▶LBL "Q(z)"

02 X<0?

03 AON

04 ABS

05 ENTER

06 X^2

07 -2

08 ÷

09 E^X

10 PI

11 STO+ ST X

12 SQRT

13 ÷

14 STO 02

15 X<>Y

16 2,32

17 X>Y?

18 GTO 02

19 Rv

20 STO 04

21 STO 06

22 ÷

23 STO 05

24 CLX

25 STO 00

26 STO 01

27 SIGN

28 STO 03

29▶LBL 01

30 ISG 00

31 CLD

32 RCL 01

33 RCL× 00

34 RCL 02

35 STO 01

36 RCL× 06

37 +

38 STO 02

39 RCL 03

40 RCL× 00

41 RCL 04

42 STO 03

43 RCL× 06

44 +

45 STO 04

46 ÷

47 ENTER

48 X<> 05

49 -

50 RCL÷ ST L

51 ABS

52 -9

53 10^X

54 X≤Y?

55 GTO 01

56 SIGN

57 RCL 05

58 FS? 48

59 -

60 GTO 09

61▶LBL 02

62 SIGN

63 STO 00

64 Rv

65 ×

66 STO 01

67 LASTX

68 X^2

69 STO 02

70 X<>Y

71▶LBL 03

72 RCL 01

73 RCL× 02

74 2

75 RCL+ 00

76 STO 00

77 ÷

78 STO 01

79 RCL+ ST Y

80 X≠Y?

81 GTO 03

82 2

83 1/X

84 FC? 48

85 +/-

86 +

87 ABS

88▶LBL 09

89 AOFF

90 END

Note: in contrast to the HP-32E the HP-21S calculates "the upper tail" of the Q function.

The formulas? If you are truly interested take a closer look to this user code routine, it is much simpler than analysing some firmware trace.

M.

Edit: replaced lines 13 1/x and 14 * by 13 / only. It was a holdover from the HP-21S, which uses the constant @03966: #0398942280401432.