plot_thomas.raw with up to two solutions

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
dk-
Posts: 16
Joined: Wed Sep 23, 2020 7:46 pm

plot_thomas.raw with up to two solutions

Post by dk- »

Hi,

I made some small modifications to Thomas' plot-program (I hope you don't mind!) to allow finding up to two solutions. It does this by searching below AXIS and above AXIS, meaning that the placement of AXIS is crucial to get good results.

For example:

Code: Select all

00 { 42-Byte Prgm }
01▸LBL "HEART"
02 MVAR "X"
03 MVAR "Y"
04 RCL "X"
05 X↑2
06 RCL "Y"
07 X↑2
08 +
09 1
10 -
11 3
12 Y↑X
13 RCL "X"
14 X↑2
15 RCL "Y"
16 3
17 Y↑X
18 ×
19 -
20 END
Plotting this function with YMIN = -1.5, YMAX = 1.5, AXIS = 0.6, XMIN = -1.5, XMAX = 1.5, XINC = 0.3 will produce a pretty heart!

The modified plot program:

Code: Select all

00 { 674-Byte Prgm }
01▸LBL "PLOT"
02 MVAR "YMIN"
03 MVAR "YMAX"
04 MVAR "AXIS"
05 MVAR "XMIN"
06 MVAR "XMAX"
07 MVAR "XINC"
08 VARMENU "PLOT"
09 "Enter limits; t"
10 ├"hen R/S"
11 PROMPT
12▸LBL 00
13 "FCN=?"
14 SF 25
15 RCL "PFCN"
16 FC?C 25
17 GTO 01
18 ├" <"
19 ARCL ST X
20 ├">"
21▸LBL 01
22 AVIEW
23 CLA
24 SF 25
25 ARCL "PFCN"
26 CF 25
27 AON
28 STOP
29 AOFF
30 ALENG
31 X=0?
32 GTO 00
33 ASTO "PFCN"
34 SF 25
35 VARMENU IND "PFCN"
36 FS?C 25
37 GTO 02
38 CLA
39 ASTO "PIND"
40 GTO 05
41▸LBL 02
42 "Set vars; selec"
43 ├"t 'x'"
44 PROMPT
45 ASTO "PIND"
46 ALENG
47 X=0?
48 GTO 02
49 CLMENU
50 "EVAL"
51 KEY 1 GTO 03
52 "SOLVE"
53 KEY 2 GTO 04
54 MENU
55 "Evaluate or sol"
56 ├"ve?"
57 PROMPT
58▸LBL 03
59 CLA
60 ASTO "PDEP"
61 GTO 05
62▸LBL 04
63 VARMENU IND "PFCN"
64 "Select 'y'"
65 PROMPT
66 ASTO "PDEP"
67▸LBL 05
68 EXITALL
69 PRON
70 ADV
71 "Plot of:"
72 PRA
73 ADV
74 SF 12
75 CLA
76 ARCL "PFCN"
77 PRA
78 ADV
79 CF 12
80 PRV "YMIN"
81 PRV "YMAX"
82 PRV "AXIS"
83 PRV "XMIN"
84 PRV "XMAX"
85 PRV "XINC"
86 ADV
87 "← YMIN"
88 ├"       YMAX →[LF]"
89 PRA
90 130
91 RCL "YMAX"
92 RCL- "YMIN"
93 ÷
94 STO 00
95 RCL "XMIN"
96 STO 01
97 CLA
98 ARCL "PIND"
99 ALENG
100 X≠0?
101 GTO 14
102 7
103 STO 03
104 GTO 06
105▸LBL 14
106 CLA
107 ARCL "PDEP"
108 ALENG
109 X≠0?
110 GTO 14
111 8
112 STO 03
113 GTO 06
114▸LBL 14
115 9
116 STO 03
117 PGMSLV IND "PFCN"
118▸LBL 06
119 CLLCD
120 FC? 00
121 XEQ 11
122 FC? 01
123 XEQ 12
124 1.016
125 STO 02
126 GTO IND 03
127▸LBL 07
128 RCL 01
129 XEQ IND "PFCN"
130 GTO 14
131▸LBL 08
132 RCL 01
133 STO IND "PIND"
134 XEQ IND "PFCN"
135 GTO 14
136▸LBL 09
137 RCL 01
138 STO IND "PIND"
139 RCL "AXIS"
140 STO IND "PDEP"
141 RCL "YMAX"
142 SOLVE IND "PDEP"
143 R↑
144 X≠0?
145 GTO 15
146 R↓
147 RCL- "YMIN"
148 RCL× 00
149 1
150 +
151 CF 24
152 RCL 02
153 X<>Y
154 X>0?
155 PIXEL
156▸LBL 15
157 RCL "YMIN"
158 STO IND "PDEP"
159 RCL "AXIS"
160 SOLVE IND "PDEP"
161 R↑
162 X≠0?
163 GTO 16
164 R↓
165▸LBL 14
166 RCL- "YMIN"
167 RCL× 00
168 1
169 +
170 CF 24
171 RCL 02
172 X<>Y
173 X>0?
174 PIXEL
175▸LBL 16
176 RCL "XINC"
177 16
178 ÷
179 STO+ 01
180 RCL "XMAX"
181 RCL 01
182 X>Y?
183 GTO 10
184 ISG 02
185 GTO IND 03
186 PRLCD
187 GTO 06
188▸LBL 10
189 PRLCD
190 RTN
191▸LBL 11
192 CF 21
193 CLA
194 ARCL 01
195 AVIEW
196 SF 21
197 RTN
198▸LBL 12
199 1
200 RCL "AXIS"
201 RCL- "YMIN"
202 RCL× 00
203 +/-
204 1
205 -
206 X≥0?
207 RTN
208 PIXEL
209 +/-
210 2
211 -
212 "×××××"
213 AGRAPH
214 END
Post Reply