Q2X uses matrix

This commit is contained in:
Dennis Twardowsky
2020-02-12 23:34:37 +01:00
parent 7535181ac1
commit adc3f7d3ff

View File

@@ -1,7 +1,8 @@
00 { 172-Byte Prgm } 00 { 168-Byte Prgm }
01 LBL "Q2F" 01 LBL "Q2F"
03 CLRG 02 CLRG
03 CF 01
// Save Stack // Save Stack
04 STO 01 04 STO 01
@@ -35,17 +36,20 @@
29 STO 05 29 STO 05
// Init counter // Init counter
30 RCL "Q2MAX" //30 RCL "Q2MAX"
31 X=0? //31 X=0?
32 12 30 12
33 1000 31 1
34 ÷ 32 X<>Y
35 0.00001 33 DIM "Q2XM"
36 + 34 1000
37 STO 06 35 ÷
38 10 36 1.00001
39 STO 07 37 +
38 STO 06
39 INDEX "Q2XM"
// Start with value from X
40 CLST 40 CLST
41 RCL 01 41 RCL 01
@@ -53,88 +57,82 @@
42 LBL A 42 LBL A
43 ENTER 43 ENTER
44 IP 44 IP
45 STO IND 07 45 STOEL
46 X<>Y 46 J+
47 FP 47 X<>Y
48 STO 08 48 FP
49 STO 08
// Check if configured tolerance is reached --> goto B // Check if configured tolerance is reached --> goto B
49 RCL 05 50 RCL 05
50 X>Y? 51 X>Y?
51 GTO B 52 GTO B
// .. if not, roll-down check value // .. if not, roll-down check value
52 R↓ 53 R↓
// ... and invert result for next round // ... and invert result for next round
53 1/X 54 1/X
// Increase REG-index
54 1
55 STO+ 07
56 R↓
// Proceed, if max num of rounds is reached --> repeat A // Proceed, if max num of rounds is reached --> repeat A
57 ISG 06 55 ISG 06
58 GTO A 56 GTO A
// Set Flag 1 to indicate max rounds reached
57 SF 01
// [LOOP-END] Build continued fraction // [LOOP-END] Build continued fraction
59 GTO C 58 GTO C
// [[B]] FINISHED building continued fraction by tolerance // [[B]] FINISHED building continued fraction by tolerance
60 LBL B 59 LBL B
// Remove last stack entry used for tolerance check // Remove last stack entry used for tolerance check
61 R↓ 60 R↓
// [[C]] FINISHED building continued fraction by max num of rounds // [[C]] FINISHED building continued fraction by max num of rounds
62 LBL C 61 LBL C
// ... and reduce matrix-index, because it was increased by previous loop.
62 J-
// Init loop for reverse calculation from old value // Init loop for reverse calculation from old value
63 RCL 06 63 RCLIJ
64 IP 64 0.00101
65 0.00001 65 +
66 + 66 STO 06
67 STO 06
// Start calculation of final fraction // Start calculation of final fraction
// NOTE: 1. fraction always has nominator =1 // NOTE: 1. fraction always has nominator =1
68 CLST 67 1
69 1 68 RCLEL
70 RCL IND 07
71 PRSTK
// [[D]] [LOOP-BEGIN] Reverse calculation // [[D]] [LOOP-BEGIN] Reverse calculation
72 LBL D 69 LBL D
73 ENTER 70 ENTER
74 R↓ 71 R↓
75 X<>Y 72 X<>Y
76 R↑ 73 R↑
// Decrease REG-index 74 J-
77 1 75 RCLEL
78 STO- 07 76 ×
79 CLX 77 +
80 RCL IND 07 78 DSE 06
81 × 79 GTO D
82 +
83 PRSTK
84 DSE 06
85 GTO D
// [LOOP-END] Perform reverse calculation // [LOOP-END] Perform reverse calculation
// Prepare Alpha-Register // Prepare Alpha-Register
86 CLA 80 CLA
87 AIP 81 AIP
88 X<>Y 82 X<>Y
89 ⊢"/" 83 ⊢"/"
90 AIP 84 AIP
// Revert Stack // Revert Stack
91 RCL 04 85 RCL 04
92 RCL 03 86 RCL 03
93 RCL 02 87 RCL 02
94 RCL 01 88 RCL 01
// Show Result // Show Result
//90 AVIEW //90 AVIEW
95 END 89 END