Basic Trig Functions for the HP-12C

01 57.29577951 ; 180/pi: degree to radian conversion factor

12 /

13 STO 0

14 STO 1

15 1

16 STO 3 ; n:=1

17 9 ; steps 17 to 23 provide automatic accuracy

18 1/x ; according to the current number of decimal

19 ENTER ; places in the display

20 RND ;

21 - ;

22 12x ; intended to multiply by 10, used the built-in

23 STO 4 ; 12x instead in order to save two steps.

24 RCL 3

25 2 * 1 +

29 ENTER ENTER

31 RCL 0

32 x<>y

33 y^x

34 x<>y

35 n!

36 /

37 ENTER

38 1 CHS

40 RCL 3

41 y^x *

43 STO + 1

44 1

45 STO + 3 ; n:=n+1

46 ROLLDN ;

47 ENTER * SQRT ; these are equivalent to ABS

50 RCL 4

51 x=<y

52 GTO 24

53 1

54 RCL 1 ; sin(x)

55 ENTER

56 * - SQRT ; cos(x)

59 STO 2

60 RCL 1Usage:

Enter angle in degrees, 0 =< x <= 180 (prefer however the

range of 0 to +/-90 degrees for greater speed and accuracy). This

range is for sine only. The range for cosine is 0 to 90 degrees.R/S => sin(x)

x<>y => cos(x)

/ => tan(x)

Registers:

R0: angle converted to radians

R1: sin(x)

R2: cos(x)

R3: number of iterations minus 1

R4: accuracyRunning time will depend upon the number of selected decimal places:

Ex.: sin(30.0)=0.5 (0.4996741794, 1 iteration, 5.5 s)

sin(30.000)=0.500 (0.5000021326, 2 iterations, 8.5 s)

sin(30.0000)=0.5000 (0.4999999919, 3 iterations, 11.5 s)

sin(30.00000000)=0.50000000 (0.5000000001, 4 iterations, 14.5 s)Reference:

sin(x) = x + SUM{n=1, inf, [(-1)^n . x^(2n+1)]/(2n+1)!}; 0 =< x =< pi

cos(x) = SQRT[1 - sin^2(x)];

tan(x) = sin(x)/cos(x)

http://www.rskey.org/gene/calcgene/38trig.htm (got the sine expansion there, which I had already forgotten).

Regards,

GWB

*Edited: 6 Feb 2005, 10:06 p.m. after one or more responses were posted*