Linear regression analysis program with graph plot for DM42

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: http://www.swissmicros.com/dm42/decoder/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
keithdalby
Posts: 399
Joined: Mon Apr 24, 2017 6:38 pm

Linear regression analysis program with graph plot for DM42

Post by keithdalby » Mon Feb 12, 2018 9:29 am

Here is my linear regression graph plotting program, which gives gradients, intercepts and standard errors in both (correctly!). It uses a menu too, and the graph can be manipulated in a few ways: explained below.

First, the code, including my timing programs too (sorry).

Code: Select all

00 { 2231-Byte Prgm }
01▸LBL "GRAPH"
02 FC? 81
03 CF 01
04 FS? 81
05 RCL "DAT"
06 STO "DAT"
07 CLST
08 RCL "DAT"
09 SF 81
10 "PLOT"
11 KEY 1 XEQ 31
12 "CHNGE"
13 KEY 2 GTO 36
14 "GRAD"
15 KEY 3 XEQ 32
16 "ErGrd"
17 KEY 4 GTO 33
18 "INTCT"
19 KEY 5 GTO 34
20 "ErInt"
21 KEY 6 GTO 35
22 KEY 9 GTO 30
23 MENU
24 STOP
25 GTO "GRAPH"
26▸LBL 36
27 "BACK"
28 KEY 1 XEQ "GRAPH"
29 "SWAPX"
30 KEY 2 GTO 37
31 "Z↑?"
32 KEY 4 GTO 39
33 CLA
34 KEY 3 GTO 36
35 KEY 5 GTO 36
36 "CHNGE"
37 KEY 6 GTO 38
38 KEY 9 GTO 30
39 MENU
40 STOP
41 GTO 36
42▸LBL 39
43 RCL "DAT"
44 STO "PROCESS"
45 DIM?
46 X<>Y
47 STO "JMAX"
48 CLST
49 "POWER?"
50 AVIEW
51 INPUT "POW"
52 CLST
53 "AXIS? X=1, Y=2"
54 AVIEW
55 INPUT "AXIS"
56 1
57 STO "J"
58 INDEX "PROCESS"
59▸LBL 44
60 RCL "J"
61 RCL "AXIS"
62 STOIJ
63 RCLEL
64 RCL "POW"
65 Y↑X
66 STOEL
67 1
68 STO+ "J"
69 RCL "J"
70 RCL "JMAX"
71 X≥Y?
72 GTO 44
73 CLST
74 RCL "PROCESS"
75 STO "DAT"
76 CLV "PROCESS"
77 CLV "JMAX"
78 CLV "POW"
79 "DONE"
80 AVIEW
81 CLV "J"
82 CLV "AXIS"
83 GTO 36
84▸LBL 38
85 "NEEDS A PROG NA"
86 ├"MED    "CHANGE"
87 ├"", OK?"
88 PROMPT
89 RCL "DAT"
90 STO "PROCESS"
91 DIM?
92 X<>Y
93 STO "JMAX"
94 "AXIS? X=1, Y=2"
95 AVIEW
96 INPUT "AXIS"
97 1
98 STO "J"
99 INDEX "PROCESS"
100▸LBL 42
101 RCL "J"
102 RCL "AXIS"
103 STOIJ
104 RCLEL
105 XEQ "CHANGE"
106 STOEL
107 1
108 STO+ "J"
109 RCL "J"
110 RCL "JMAX"
111 X≥Y?
112 GTO 42
113 CLST
114 RCL "PROCESS"
115 STO "DAT"
116 CLV "PROCESS"
117 CLV "JMAX"
118 "DONE"
119 AVIEW
120 CLV "J"
121 CLV "AXIS"
122 GTO 36
123▸LBL 37
124 CLST
125 RCL "DAT"
126 STO "TEMP"
127 1
128 STO "J"
129 RCL "TEMP"
130 DIM?
131 X<>Y
132 STO "MAXJ"
133 INDEX "TEMP"
134▸LBL 41
135 RCL "J"
136 1
137 STOIJ
138 RCLEL
139 RCL "J"
140 2
141 STOIJ
142 RCLEL
143 R↓
144 R↓
145 R↓
146 RCL "J"
147 2
148 STOIJ
149 R↓
150 R↓
151 STOEL
152 RCL "J"
153 1
154 STOIJ
155 R↓
156 R↓
157 R↓
158 STOEL
159 1
160 STO+ "J"
161 RCL "J"
162 RCL "MAXJ"
163 X≥Y?
164 GTO 41
165 RCL "TEMP"
166 STO "DAT"
167 CLV "J"
168 CLV "JMAX"
169 CLV "TEMP"
170 FC?C 01
171 SF 02
172 FS?C 02
173 SF 01
174 FS? 01
175 "DONE (INVERTED)"
176 FC? 01
177 "DONE (UNINVERTE"
178 FC? 01
179 ├"D)"
180 PROMPT
181 CLA
182 GTO 36
183▸LBL 30
184 CF 81
185 CF 01
186 CLV "MAXJ"
187 CLV "DINT"
188 CLV "JMAX"
189 CLV "PROCESS"
190 CLA
191 EXITALL
192 STOP
193▸LBL 31
194 2
195 STO "GrMod"
196 CLLCD
197 RCL "DAT"
198 DIM?
199 X<>Y
200 STO "MAXJ"
201 INDEX "DAT"
202 1
203 STO "J"
204 1
205 RCL "J"
206 X<>Y
207 STOIJ
208 RCLEL
209 STO "MINX"
210 STO "MAXX"
211 2
212 RCL "J"
213 X<>Y
214 STOIJ
215 RCLEL
216 STO "MINY"
217 STO "MAXY"
218▸LBL 01
219 1
220 STO+ "J"
221 RCL "MAXJ"
222 RCL "J"
223 X>Y?
224 GTO 03
225 1
226 RCL "J"
227 X<>Y
228 STOIJ
229 RCLEL
230 STO "TEMP"
231 RCL "MAXX"
232 RCL "TEMP"
233 X>Y?
234 STO "MAXX"
235 RCL "MINX"
236 RCL "TEMP"
237 X<Y?
238 STO "MINX"
239 2
240 RCL "J"
241 X<>Y
242 STOIJ
243 RCLEL
244 STO "TEMP"
245 RCL "MAXY"
246 RCL "TEMP"
247 X>Y?
248 STO "MAXY"
249 RCL "MINY"
250 RCL "TEMP"
251 X<Y?
252 STO "MINY"
253 GTO 01
254▸LBL 03
255 1
256 STO "J"
257▸LBL 02
258 RCL "J"
259 1
260 STOIJ
261 RCLEL
262 RCL "MINX"
263 -
264 RCL "MAXX"
265 RCL "MINX"
266 -
267 ÷
268 198
269 ×
270 2
271 +
272 STO "TX"
273 RCL "J"
274 2
275 STOIJ
276 RCLEL
277 RCL "MINY"
278 -
279 RCL "MAXY"
280 RCL "MINY"
281 -
282 ÷
283 -118
284 ×
285 120
286 +
287 STO "TY"
288 RCL "TX"
289 PIXEL
290 RCL "TY"
291 1
292 +
293 RCL "TX"
294 1
295 +
296 PIXEL
297 RCL "TY"
298 1
299 -
300 RCL "TX"
301 1
302 +
303 PIXEL
304 RCL "TY"
305 1
306 -
307 RCL "TX"
308 1
309 -
310 PIXEL
311 RCL "TY"
312 1
313 +
314 RCL "TX"
315 1
316 -
317 PIXEL
318 1
319 STO+ "J"
320 RCL "J"
321 RCL "MAXJ"
322 X≥Y?
323 GTO 02
324 1
325 STO "I"
326 1
327 STO "J"
328 0
329 RCL "MINX"
330 -
331 RCL "MAXX"
332 RCL "MINX"
333 -
334 ÷
335 198
336 ×
337 2
338 +
339 STO "0I"
340 0
341 RCL "MINY"
342 -
343 RCL "MAXY"
344 RCL "MINY"
345 -
346 ÷
347 -118
348 ×
349 120
350 +
351 STO "0J"
352 RCL "MINX"
353 0
354 X<Y?
355 GTO 05
356 RCL "MAXX"
357 0
358 X>Y?
359 GTO 05
360▸LBL 04
361 RCL "J"
362 RCL "0I"
363 PIXEL
364 1
365 STO+ "J"
366 RCL "J"
367 120
368 X≥Y?
369 GTO 04
370▸LBL 05
371 RCL "MINY"
372 0
373 X<Y?
374 GTO 06
375 RCL "MAXY"
376 0
377 X>Y?
378 GTO 06
379 RCL "0J"
380 RCL "I"
381 PIXEL
382 1
383 STO+ "I"
384 RCL "I"
385 198
386 X≥Y?
387 GTO 05
388▸LBL 06
389 CLV "0J"
390 CLV "0I"
391 CLV "TY"
392 CLV "TX"
393 CLV "TEMP"
394 CLV "J"
395 RCL "DAT"
396 CLΣ
397 Σ+
398 LINF
399 0
400 SLOPE
401 STO "GRAD"
402 YINT
403 STO "INT"
404 CORR
405 STO "PMCC"
406 1
407 ENTER
408 STO "I"
409▸LBL 72
410 RCL "I"
411 200
412 ÷
413 RCL "MAXX"
414 RCL "MINX"
415 -
416 ×
417 RCL "MINX"
418 +
419 RCL "GRAD"
420 ×
421 RCL "INT"
422 +
423 STO "LY"
424 RCL "LY"
425 RCL "MINY"
426 -
427 120
428 ×
429 RCL "MAXY"
430 RCL "MINY"
431 -
432 ÷
433 +/-
434 122
435 +
436 STO "J"
437 RCL "J"
438 1
439 X>Y?
440 GTO 75
441 RCL "J"
442 120
443 X<Y?
444 GTO 75
445 RCL "J"
446 RCL "I"
447 PIXEL
448▸LBL 75
449 1
450 ENTER
451 RCL "I"
452 +
453 STO "I"
454 RCL "I"
455 200
456 X≥Y?
457 GTO 72
458 CLV "J"
459 CLV "LY"
460 CLV "I"
461 CLV "MAXY"
462 CLV "MINY"
463 CLV "MAXX"
464 CLV "MINX"
465 CLST
466 STOP
467 RCL "DAT"
468 RTN
469▸LBL 32
470 "y=mx+c, m="
471 CLST
472 RCL "GRAD"
473 ARCL ST X
474 PROMPT
475 CLST
476 RTN
477▸LBL 33
478 "y=mx+c, Dm="
479 CLST
480 RCL "GRAD"
481 RCL 14
482 RCL 13
483 X↑2
484 RCL 16
485 ÷
486 -
487 RCL 15
488 RCL 11
489 RCL 13
490 ×
491 RCL 16
492 ÷
493 -
494 RCL "GRAD"
495 ×
496 -
497 RCL 16
498 2
499 -
500 ÷
501 X↑2
502 SQRT
503 RCL 16
504 ÷
505 RCL 12
506 RCL 11
507 X↑2
508 RCL 16
509 ÷
510 -
511 ÷
512 SQRT
513 STO "DGRAD"
514 CLST
515 RCL "GRAD"
516 RCL "DGRAD"
517 ARCL ST X
518 PROMPT
519 CLST
520 RTN
521▸LBL 34
522 "y=mx+c, c="
523 CLST
524 RCL "INT"
525 ARCL ST X
526 PROMPT
527 CLST
528 RTN
529▸LBL 35
530 "y=mx+c, Dc="
531 RCL "GRAD"
532 RCL 14
533 RCL 13
534 X↑2
535 RCL 16
536 ÷
537 -
538 RCL 15
539 RCL 11
540 RCL 13
541 ×
542 RCL 16
543 ÷
544 -
545 RCL "GRAD"
546 ×
547 -
548 RCL 16
549 2
550 -
551 ÷
552 X↑2
553 SQRT
554 RCL 11
555 RCL 16
556 ÷
557 X↑2
558 RCL 11
559 X↑2
560 RCL 16
561 ÷
562 +/-
563 RCL 12
564 +
565 ÷
566 RCL 16
567 1/X
568 +
569 RCL 16
570 ÷
571 ×
572 SQRT
573 STO "DINT"
574 CLST
575 RCL "INT"
576 RCL "DINT"
577 ARCL ST X
578 PROMPT
579 CLST
580 RTN
581 CLA
582 CLV "MAXJ"
583 CLV "JMAX"
584 RCL "DAT"
585 END
586▸LBL "TIMER"
587 "HOW MANY OSCILL"
588 ├"ATIONS?"
589 AVIEW
590 INPUT "N"
591 0
592 STO "M"
593 "PRESS TO START."
594 PROMPT
595 "ITERATION:"
596 TIME
597 →HR
598 3600
599 ×
600 STO "T0"
601▸LBL 01
602 CLST
603 RCL "M"
604 PROMPT
605 1
606 STO+ "M"
607 RCL "M"
608 RCL "N"
609 X>Y?
610 GTO 01
611 TIME
612 →HR
613 3600
614 ×
615 RCL "T0"
616 -
617 STO "T"
618 "FULL TIME="
619 RCL "T"
620 SF 26
621 TONE 9
622 CF 26
623 PROMPT
624 RCL "N"
625 ÷
626 STO "DT"
627 "TIME PER OSCILL"
628 ├"ATION="
629 RCL "DT"
630 PROMPT
631 CLST
632 RCL "T"
633 RCL "DT"
634 CLV "T0"
635 CLV "M"
636 CLV "N"
637 END
638▸LBL "INTVL"
639 1
640 STO "N"
641 "SECONDS INTERVA"
642 ├"L?"
643 AVIEW
644 INPUT "DT"
645 TIME
646 →HR
647 3600
648 ×
649 STO "T"
650▸LBL 01
651 RCL "T"
652 RCL "DT"
653 +
654 STO "T"
655▸LBL 02
656 TIME
657 →HR
658 3600
659 ×
660 RCL "T"
661 X>Y?
662 GTO 02
663 "TIME/SEC="
664 RCL "N"
665 RCL "DT"
666 ×
667 AIP
668 AVIEW
669 SF 26
670 TONE 9
671 CF 26
672 1
673 STO+ "N"
674 GTO 01
675 END
676 PROFF
677▸LBL "CLOCK"
678 TIME
679 →HR
680 3600
681 ×
682 STO "T0"
683▸LBL 01
684 "TIME/MS="
685 TIME
686 →HR
687 3600
688 ×
689 RCL "T0"
690 -
691 1ᴇ3
692 ×
693 AIP
694 AVIEW
695 GTO 01
696 STOP
697 END
698▸LBL "CLS"
699 CLST
700 X↑2
701 CLA
702 END
703▸LBL "CHANGE"
704 X↑2
705 END
Next, the .raw file.
labs2.zip
(1.28 KiB) Downloaded 2 times
To use, place a matrix on the X-register with dimensions Zx2, where Z is the number of data points. The left column of the matrix is the x-axis values and the right column of the matrix is the y-axis values.

On running the program GRAPH, you see this.
20180212-09073597.jpg
20180212-09073597.jpg (77.27 KiB) Viewed 117 times
On pressing PLOT , you see this (autoscaled).
20180212-09082753.jpg
20180212-09082753.jpg (12.92 KiB) Viewed 117 times
You can exit out of this by pressing a different menu button (not the F1 button, that just redraws the graph. Maybe I'll change that to a 'BACK' button in a later version) or pressing R/S.
The other buttons that show gradient, error in gradient, intercept and error in intercept all show the values on the screen using the current display settings (to be updated in a future version) and leave values on the stack if you EXIT out. Pressing the CHNGE allows some graph manupulation, such as SWAPX which swaps the X and Y axes around (and indicates such with the flag 1 being set), Z^? raises an axis to a power (2, 0.5, -1, whatever you like, first you give the power, then you choose the axis to affect) and CHNGE does some other change to a given axis, but needs a program called CHANGE with the change to implement.

The menu works pretty well, and I'm happy with the outcome so far. I just need to tweak the display settings - I want the program to choose 3-sigfig SCI notation for the gradients, intercepts and errors being displayed, then return to the previous settings when the program is EXITed. Shouldn't be too tricky to do at some time soon.

Please let me know what you think and what I need to do to improve it. If it's broken, let me know! Uses the default statistical registers, Flag 1, 2 and Flag 81.

User avatar
Walter
Posts: 585
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

Re: Linear regression analysis program with graph plot for DM42

Post by Walter » Mon Feb 12, 2018 10:20 am

DM42 SN: 00041 --- Follower of Platon.

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

keithdalby
Posts: 399
Joined: Mon Apr 24, 2017 6:38 pm

Re: Linear regression analysis program with graph plot for DM42

Post by keithdalby » Mon Feb 12, 2018 10:33 am

Walter wrote:
Mon Feb 12, 2018 10:20 am
Are you aware of this: http://www.hpmuseum.org/forum/thread-10110.html ?
Interesting. I've met this before. The differences for what we deal with in a high-school lab are small enough to be ignored. I wrote a [rather unsophisticated] Monte Carlo algorithm for Excel to get an alternative method of forming gradients, intercepts and their standard errors. It estimates errors around three times larger (or there abouts, does depend on the data, obviously), with values of gradient and intercept that lie well within the errors of each other (Monte Carlo compared against least squares). The way high schoolers have to estimate errors is mostly by eye, and high-school-endorsed estimates of errors tend to be even higher than the Monte Carlo estimates.

I share this guff with my A Level (ages 16-18) Physics students to help them justify to themselves why estimating errors by eye is acceptable. They often believe that physics, like mathematics, is pure and perfect. When they meet errors for the first time, they assume there's a 'correct' way to analyse them. Of course, every method produces estimates based on different assumptions. After meeting this idea, they're happier estimating errors using a less-rigorous method.

I wonder if I can program a Monte Carlo method into my DM-42 {he says, musing to himself}. It needs to randomly sample pairs of data points 20,000 times to produce a worthwhile estimate (~1% error in the error values). Might not have time to play with that until this summer.

Anyway, thank you for sharing Walter.

Edit to add: one-button axis swapping makes the issues in Walter's link easy to investigate :)

keithdalby
Posts: 399
Joined: Mon Apr 24, 2017 6:38 pm

Re: Linear regression analysis program with graph plot for DM42

Post by keithdalby » Mon Feb 12, 2018 5:51 pm

The regression analysis program including preservation of user display state. I am sorry for the twistiest of spaghetti coding, I can write structured code but for some reason FOCAL just takes me right back to playing around with BASIC and bad habits return. Plus, not convinced FOCAL is that good for structured programming either.

As before, this program needs a matrix in the X-register when it is run, with Zx2 dimensions where Z is the number of data points. EXITing out of the program restores the previous display state.

Code: Select all

00 { 2017-Byte Prgm }
01▸LBL "GRAPH"
02 GTO 95
03▸LBL 96
04 CLST
05 0
06 FS? 36
07 1
08 8
09 ×
10 0
11 FS? 37
12 1
13 4
14 ×
15 +
16 0
17 FS? 38
18 1
19 2
20 ×
21 +
22 0
23 FS? 39
24 1
25 +
26 +
27 STO "DIGITS"
28 CLST
29 10
30 FS? 40
31 1
32 ×
33 STO "DMODE"
34 CLST
35 1
36 FS? 41
37 1
38 ×
39 STO+ "DMODE"
40 CLST
41 RTN
42▸LBL 95
43 FC? 81
44 CF 01
45 FS? 81
46 RCL "DAT"
47 STO "DAT"
48 FC? 81
49 XEQ 96
50 SCI 04
51 CLST
52 RCL "DAT"
53 SF 81
54 "PLOT"
55 KEY 1 XEQ 31
56 "CHNGE"
57 KEY 2 GTO 36
58 "GRAD"
59 KEY 3 XEQ 32
60 "ErGrd"
61 KEY 4 GTO 33
62 "INTCT"
63 KEY 5 GTO 34
64 "ErInt"
65 KEY 6 GTO 35
66 KEY 9 GTO 30
67 MENU
68 STOP
69 GTO "GRAPH"
70▸LBL 36
71 "BACK"
72 KEY 1 XEQ "GRAPH"
73 "SWAPX"
74 KEY 2 GTO 37
75 "Z↑?"
76 KEY 4 GTO 39
77 CLA
78 KEY 3 GTO 36
79 KEY 5 GTO 36
80 "CHNGE"
81 KEY 6 GTO 38
82 KEY 9 GTO 30
83 MENU
84 STOP
85 GTO 36
86▸LBL 39
87 RCL "DAT"
88 STO "PROCESS"
89 DIM?
90 X<>Y
91 STO "JMAX"
92 CLST
93 "POWER?"
94 AVIEW
95 INPUT "POW"
96 CLST
97 "AXIS? X=1, Y=2"
98 AVIEW
99 INPUT "AXIS"
100 1
101 STO "J"
102 INDEX "PROCESS"
103▸LBL 44
104 RCL "J"
105 RCL "AXIS"
106 STOIJ
107 RCLEL
108 RCL "POW"
109 Y↑X
110 STOEL
111 1
112 STO+ "J"
113 RCL "J"
114 RCL "JMAX"
115 X≥Y?
116 GTO 44
117 CLST
118 RCL "PROCESS"
119 STO "DAT"
120 CLV "PROCESS"
121 CLV "JMAX"
122 CLV "POW"
123 "DONE"
124 AVIEW
125 CLV "J"
126 CLV "AXIS"
127 GTO 36
128▸LBL 38
129 "NEEDS A PROG NA"
130 ├"MED    "CHANGE"
131 ├"", OK?"
132 PROMPT
133 RCL "DAT"
134 STO "PROCESS"
135 DIM?
136 X<>Y
137 STO "JMAX"
138 "AXIS? X=1, Y=2"
139 AVIEW
140 INPUT "AXIS"
141 1
142 STO "J"
143 INDEX "PROCESS"
144▸LBL 42
145 RCL "J"
146 RCL "AXIS"
147 STOIJ
148 RCLEL
149 XEQ "CHANGE"
150 STOEL
151 1
152 STO+ "J"
153 RCL "J"
154 RCL "JMAX"
155 X≥Y?
156 GTO 42
157 CLST
158 RCL "PROCESS"
159 STO "DAT"
160 CLV "PROCESS"
161 CLV "JMAX"
162 "DONE"
163 AVIEW
164 CLV "J"
165 CLV "AXIS"
166 GTO 36
167▸LBL 37
168 CLST
169 RCL "DAT"
170 STO "TEMP"
171 1
172 STO "J"
173 RCL "TEMP"
174 DIM?
175 X<>Y
176 STO "MAXJ"
177 INDEX "TEMP"
178▸LBL 41
179 RCL "J"
180 1
181 STOIJ
182 RCLEL
183 RCL "J"
184 2
185 STOIJ
186 RCLEL
187 R↓
188 R↓
189 R↓
190 RCL "J"
191 2
192 STOIJ
193 R↓
194 R↓
195 STOEL
196 RCL "J"
197 1
198 STOIJ
199 R↓
200 R↓
201 R↓
202 STOEL
203 1
204 STO+ "J"
205 RCL "J"
206 RCL "MAXJ"
207 X≥Y?
208 GTO 41
209 RCL "TEMP"
210 STO "DAT"
211 CLV "J"
212 CLV "JMAX"
213 CLV "TEMP"
214 FC?C 01
215 SF 02
216 FS?C 02
217 SF 01
218 FS? 01
219 "DONE (INVERTED)"
220 FC? 01
221 "DONE (UNINVERTE"
222 FC? 01
223 ├"D)"
224 PROMPT
225 CLA
226 GTO 36
227▸LBL 30
228 CF 81
229 CF 01
230 RCL "DMODE"
231 ENTER
232 ENTER
233 ENTER
234 0
235 X=Y?
236 SCI IND "DIGITS"
237 R↓
238 1
239 X=Y?
240 ENG IND "DIGITS"
241 R↓
242 10
243 X=Y?
244 FIX IND "DIGITS"
245 R↓
246 11
247 X=Y?
248 ALL
249 CLST
250 CLV "DMODE"
251 CLV "DIGITS"
252 CLV "MAXJ"
253 CLV "DINT"
254 CLV "JMAX"
255 CLV "PROCESS"
256 CLA
257 EXITALL
258 STOP
259▸LBL 31
260 "BACK"
261 KEY 1 GTO "GRAPH"
262 MENU
263 2
264 STO "GrMod"
265 CLLCD
266 RCL "DAT"
267 DIM?
268 X<>Y
269 STO "MAXJ"
270 INDEX "DAT"
271 1
272 STO "J"
273 1
274 RCL "J"
275 X<>Y
276 STOIJ
277 RCLEL
278 STO "MINX"
279 STO "MAXX"
280 2
281 RCL "J"
282 X<>Y
283 STOIJ
284 RCLEL
285 STO "MINY"
286 STO "MAXY"
287▸LBL 01
288 1
289 STO+ "J"
290 RCL "MAXJ"
291 RCL "J"
292 X>Y?
293 GTO 03
294 1
295 RCL "J"
296 X<>Y
297 STOIJ
298 RCLEL
299 STO "TEMP"
300 RCL "MAXX"
301 RCL "TEMP"
302 X>Y?
303 STO "MAXX"
304 RCL "MINX"
305 RCL "TEMP"
306 X<Y?
307 STO "MINX"
308 2
309 RCL "J"
310 X<>Y
311 STOIJ
312 RCLEL
313 STO "TEMP"
314 RCL "MAXY"
315 RCL "TEMP"
316 X>Y?
317 STO "MAXY"
318 RCL "MINY"
319 RCL "TEMP"
320 X<Y?
321 STO "MINY"
322 GTO 01
323▸LBL 03
324 1
325 STO "J"
326▸LBL 02
327 RCL "J"
328 1
329 STOIJ
330 RCLEL
331 RCL "MINX"
332 -
333 RCL "MAXX"
334 RCL "MINX"
335 -
336 ÷
337 198
338 ×
339 2
340 +
341 STO "TX"
342 RCL "J"
343 2
344 STOIJ
345 RCLEL
346 RCL "MINY"
347 -
348 RCL "MAXY"
349 RCL "MINY"
350 -
351 ÷
352 -118
353 ×
354 120
355 +
356 STO "TY"
357 RCL "TX"
358 PIXEL
359 RCL "TY"
360 1
361 +
362 RCL "TX"
363 1
364 +
365 PIXEL
366 RCL "TY"
367 1
368 -
369 RCL "TX"
370 1
371 +
372 PIXEL
373 RCL "TY"
374 1
375 -
376 RCL "TX"
377 1
378 -
379 PIXEL
380 RCL "TY"
381 1
382 +
383 RCL "TX"
384 1
385 -
386 PIXEL
387 1
388 STO+ "J"
389 RCL "J"
390 RCL "MAXJ"
391 X≥Y?
392 GTO 02
393 1
394 STO "I"
395 1
396 STO "J"
397 0
398 RCL "MINX"
399 -
400 RCL "MAXX"
401 RCL "MINX"
402 -
403 ÷
404 198
405 ×
406 2
407 +
408 STO "0I"
409 0
410 RCL "MINY"
411 -
412 RCL "MAXY"
413 RCL "MINY"
414 -
415 ÷
416 -118
417 ×
418 120
419 +
420 STO "0J"
421 RCL "MINX"
422 0
423 X<Y?
424 GTO 05
425 RCL "MAXX"
426 0
427 X>Y?
428 GTO 05
429▸LBL 04
430 RCL "J"
431 RCL "0I"
432 PIXEL
433 1
434 STO+ "J"
435 RCL "J"
436 120
437 X≥Y?
438 GTO 04
439▸LBL 05
440 RCL "MINY"
441 0
442 X<Y?
443 GTO 06
444 RCL "MAXY"
445 0
446 X>Y?
447 GTO 06
448 RCL "0J"
449 RCL "I"
450 PIXEL
451 1
452 STO+ "I"
453 RCL "I"
454 198
455 X≥Y?
456 GTO 05
457▸LBL 06
458 CLV "0J"
459 CLV "0I"
460 CLV "TY"
461 CLV "TX"
462 CLV "TEMP"
463 CLV "J"
464 RCL "DAT"
465 CLΣ
466 Σ+
467 LINF
468 0
469 SLOPE
470 STO "GRAD"
471 YINT
472 STO "INT"
473 CORR
474 STO "PMCC"
475 1
476 ENTER
477 STO "I"
478▸LBL 72
479 RCL "I"
480 200
481 ÷
482 RCL "MAXX"
483 RCL "MINX"
484 -
485 ×
486 RCL "MINX"
487 +
488 RCL "GRAD"
489 ×
490 RCL "INT"
491 +
492 STO "LY"
493 RCL "LY"
494 RCL "MINY"
495 -
496 120
497 ×
498 RCL "MAXY"
499 RCL "MINY"
500 -
501 ÷
502 +/-
503 122
504 +
505 STO "J"
506 RCL "J"
507 1
508 X>Y?
509 GTO 75
510 RCL "J"
511 120
512 X<Y?
513 GTO 75
514 RCL "J"
515 RCL "I"
516 PIXEL
517▸LBL 75
518 1
519 ENTER
520 RCL "I"
521 +
522 STO "I"
523 RCL "I"
524 200
525 X≥Y?
526 GTO 72
527 CLV "J"
528 CLV "LY"
529 CLV "I"
530 CLV "MAXY"
531 CLV "MINY"
532 CLV "MAXX"
533 CLV "MINX"
534 CLST
535 STOP
536 RCL "DAT"
537 RTN
538▸LBL 32
539 "y=mx+c, m="
540 CLST
541 RCL "GRAD"
542 ARCL ST X
543 PROMPT
544 CLST
545 RTN
546▸LBL 33
547 "y=mx+c, Dm="
548 CLST
549 RCL "GRAD"
550 RCL 14
551 RCL 13
552 X↑2
553 RCL 16
554 ÷
555 -
556 RCL 15
557 RCL 11
558 RCL 13
559 ×
560 RCL 16
561 ÷
562 -
563 RCL "GRAD"
564 ×
565 -
566 RCL 16
567 2
568 -
569 ÷
570 X↑2
571 SQRT
572 RCL 16
573 ÷
574 RCL 12
575 RCL 11
576 X↑2
577 RCL 16
578 ÷
579 -
580 ÷
581 SQRT
582 STO "DGRAD"
583 CLST
584 RCL "GRAD"
585 RCL "DGRAD"
586 ARCL ST X
587 PROMPT
588 CLST
589 RTN
590▸LBL 34
591 "y=mx+c, c="
592 CLST
593 RCL "INT"
594 ARCL ST X
595 PROMPT
596 CLST
597 RTN
598▸LBL 35
599 "y=mx+c, Dc="
600 RCL "GRAD"
601 RCL 14
602 RCL 13
603 X↑2
604 RCL 16
605 ÷
606 -
607 RCL 15
608 RCL 11
609 RCL 13
610 ×
611 RCL 16
612 ÷
613 -
614 RCL "GRAD"
615 ×
616 -
617 RCL 16
618 2
619 -
620 ÷
621 X↑2
622 SQRT
623 RCL 11
624 RCL 16
625 ÷
626 X↑2
627 RCL 11
628 X↑2
629 RCL 16
630 ÷
631 +/-
632 RCL 12
633 +
634 ÷
635 RCL 16
636 1/X
637 +
638 RCL 16
639 ÷
640 ×
641 SQRT
642 STO "DINT"
643 CLST
644 RCL "INT"
645 RCL "DINT"
646 ARCL ST X
647 PROMPT
648 CLST
649 RTN
650 CLA
651 CLV "MAXJ"
652 CLV "JMAX"
653 RCL "DAT"
654 END
655▸LBL "CHANGE"
656 X↑2
657 END
And the .raw file:
lab toys.zip
(1.53 KiB) Downloaded 2 times
Apart from playing with different ways of estimating gradients, intercepts and errors, I'm happy with this program and am happy to leave it as it is, but please let me know if I can improve it.

Post Reply