for the HP 42S
Frac - Fractional approximation

Input
Resources to be used
Output

Program list (Rev.1.08 Nov. 6 2009)
Fractional approximation
using continued fraction
recompose and
calculate error
00 { 138-Byte Prgm }
01 LBL "Frac"
02 CF 00
03 ABS
04 STO 22
05 STO 23
06 1.021
07 STO 00
08 CLχ
09 χ<>y
10 LBL B
11 IP
12 STO IND 00
13 χ≠0?
14 XEQ C
15 RCL 23
16 RCL- IND 00
17 χ=0?
18 SF 00
19 FS?C 00
20 GTO E
21 1/χ
22 STO 23
23 ISG 00
24 GTO B
25 LBL E
26 R↓
27 RCL 22
28 ABS
29 CLχ
30 LASTχ
31 R↓
32 RTN
33 LBL C
34 RCL 00
35 IP
36 χ<> 00
37 STO 24
38 0
39 1
40 LBL D
41 ENTER
42 ENTER
43 RCL IND 00
44 ×
45 R↑
46 +
47 DSE 00
48 GTO D
49 ABS
50 χ<>y
51 ENTER
52 ENTER
53 LASTχ
54 ÷
55 RCL× 22
56 1
57 -
58 χ<> 24
59 STO 00
60 CLχ
61 2E-12
62 RCL 24
63 ABS
64 χ<y?
65 SF 00
66 CLχ
67 RCL 24
68 CLA
69 ARCL ST χ
70 "LF"
71 R↑
72 AIP
73 "/"
74 R↑
75 AIP
76 PROMPT
77 RTN
78 END
Examples
DISP SCI 3
π XEQ FRAC

4.720E-2
1/3
-4.023E-4
22/7
2.649E-5
333/106
-8.491E-8
355/113
1.800E-10
103993/33102
-1.060E-10
104348/33215
4.000E-11
208341/66317
-9.000E-12
312689/99532
0.000E0
833719/265381

Note: Simple continued fraction expression of π, to 12 digits accuracy.

SEE ALSO
Franctional approximation of π Japanese
Fractional approximation program for the HP-15C
Fractional approximation program for the HP-32sII
Fractional approximation program for the HP-35s
Find the nearest fraction in the E24 numbers

www.finetune.co.jp [Mail] Copyright (c) HOSODA Takayuki. All rights reserved.
Powered by
 Finetune