(03-26-2016 08:21 PM)bshoring Wrote: [ -> ]The Trig functions are working like a charm.

Even better now!

Thanks for the fun, even though today is still

Easter Sunday Eve. Well, no programming tomorrow then :-)

Gerson.

Fast and Accurate Trigonometric Functions on the RPN-38 CX Simulator
Code:

01 - 3 3

02 - 71 ÷

03 - 21 11 STO n

04 - 31 ENTER

05 - 61 ×

06 - 31 ENTER

07 - 31 ENTER

08 - 31 ENTER

09 - 22 61 8 RCL × 8

10 - 22 51 7 RCL + 7

11 - 61 ×

12 - 22 41 6 RCL − 6

13 - 61 ×

14 - 22 51 0 RCL + 0

15 - 22 11 RCL n

16 - 61 ×

17 - 31 ENTER

18 - 31 ENTER

19 - 61 ×

20 - 4 4

21 - 61 ×

22 - 32 CHS

23 - 3 3

24 - 51 +

25 - 61 ×

26 - 31 ENTER

27 - 31 ENTER

28 - 31 ENTER

29 - 61 ×

30 - 32 CHS

31 - 1 1

32 - 51 +

33 - 24 21 √x

34 - 25 7 00 GTO 00

35 - 25 6 x=0

36 - 25 7 00 GTO 00

37 - 31 ENTER

38 - 61 ×

39 - 24 71 1/x

40 - 1 1

41 - 41 −

42 - 24 71 1/x

43 - 25 7 49 GTO 49

44 - 31 ENTER

45 - 61 ×

46 - 24 71 1/x

47 - 1 1

48 - 41 −

49 - 24 21 √x

50 - 25 6 x=0

51 - 25 7 00 GTO 00

52 - 1 1

53 - 33 x≷y

54 - 25 5 x≤y

55 - 25 7 58 GTO 58

56 - 24 71 1/x

57 - 9 9

58 - 0 0

59 - 21 15 STO FV

60 - 25 33 R↓

61 - 24 71 1/x

62 - 21 11 STO n

63 - 31 ENTER

64 - 61 ×

65 - 51 +

66 - 24 21 √x

67 - 22 11 RCL n

68 - 41 −

69 - 21 11 STO n

70 - 31 ENTER

71 - 61 ×

72 - 31 ENTER

73 - 31 ENTER

74 - 31 ENTER

75 - 22 61 5 RCL × 5

76 - 22 41 4 RCL − 4

77 - 61 ×

78 - 22 51 3 RCL + 3

79 - 61 ×

80 - 22 41 2 RCL − 2

81 - 61 ×

82 - 22 51 1 RCL + 1

83 - 61 ×

84 - 3 3

85 - 24 71 1/x

86 - 41 −

87 - 61 ×

88 - 1 1

89 - 51 +

90 - 22 11 RCL n

91 - 61 ×

92 - 2 2

93 - 61 ×

94 - 22 71 0 RCL ÷ 0

95 - 22 15 RCL FV

96 - 25 6 x=0

97 - 33 x≷y

98 - 33 x≷y

99 - 41 −

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

1.745329252E-02 STO 0

0.199999779 STO 1

0.142841665 STO 2

1.107161127E-01 STO 3

0.086263068 STO 4

0.05051923 STO 5

8.860961462E-07 STO 6

1.349582775E-11 STO 7

9.73259E-17 STO 8

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

Alternatively, but no significant difference:

1745329251 ENTER 99433 + g EEX 10 / STO 0

8860961462 ENTER .4934 + g EEX 16 / STO 6

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

Usage:

Trigonometric functions:

Enter angles in degrees, -90 =< x <= 90 (*):

R/S => cos(x)

x<>y => sin(x)

x<>y / => tan(x)

GTO 35 R/S => arcsin(x)

GTO 44 R/S => arccos(x)

GTO 50 R/S => arctan(x)

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

0.0001 R/S --> 1.000000000 ; cos(0.0001)

x<>y --> 1.745329252E-06 ; sin(0.0001)

/ --> 1.745329252E-06 ; tan(0.0001)

0.9999 GTO 35 R/S --> 89.18960866 ; asin(0.9999)

0.9999 GTO 44 R/S --> 0.8102914371 ; acos(0.9999)

0.9999 GTO 50 R/S --> 44.99713507 ; atan(0.9999)

Other examples:

sin(0.01) = 0.9999999848

sin(0.01) = 1.745329243E-04

tan(0.01) = 1.745329270E-04

sin(30) = 0.8660254038

cos(30) = 0.5000000000

tan(30) = 0.5773502692

sin(60) = 0.500000000(1)

cos(60) = 0.866025403(7)

tan(60) = 1.73205080(8)

sin(89.99) = 0.9999999848

cos(89.99) = 1.7453(37879)E-4

tan(89.99) = 5729.5(49544)

sin(89.9999) = 1.000000000

cos(89.9999) = 1.7462(35540)E-6

tan(89.9999) = 572(660.4329)

asin(0) = 0.000000000

acos(0) = Error 0

atan(0) = 0.000000000

asin(1e-10) = 90.00000000

atan(0.4142135624) = 22.50000000

atan(1) = 45.00000000

acos(0.8660254038) = 30.00000000

atan(50) = 88.85423716

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

Forensic result:

9 R/S x<>y R/S R/S / GTO 50 R/S GTO 44 R/S GTO 35 R/S --> 9.000000272

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

P.S.:

(03-26-2016 08:21 PM)bshoring Wrote: [ -> ]The emulator for the HP-38C allows RCL arithmetic so in some cases I've been able to combine steps, so I can put GOTO instructions at the beginning so now I can use:

COS(x): [R/S]

SIN(x): [R/S] [x<>y]

TAN(x): [R/S] [/]

ASIN(x): [g] [GTO] 02 [R/S]

ACOS(x): [g] [GTO] 03 [R/S]

ATAN(x): [g] [GTO] 04 [R/S]

If you replace register

n with register

9 then you can save at least three steps, but I think this won't be enough. Anyway, the new labels (35, 44, and 50) are somewhat easier to remember.