1 3REM C U R F I T
2 4 REM MODIFIED FEB 6,1975
3 5 PRINT
4 6 PRINT "C U R F I T"
5 7 PRINT
6 12 PRINT "DO YOU WANT INSTURCTIONS? YES OR NO"
7 13 INPUT Q1$
8 14 IF Q1$ = "YES" THEN 20
9 15 IF Q1$ = "yes" THEN 20
10 16 IF Q1$ = "no" THEN 700
11 17 IF Q1$ = "NO" THEN 700
12 18 PRINT "ANSWER EITHER ""YES"" OR ""NO"""
13 19 GO TO 12
14 20 PRINT "LINE NUMBERS 50-699 ARE FREE FOR USE AS DATA STATEMENTS, AS REQUIRED"
15 22 PRINT "ALL VALUES FOR ONE VARIABLE ARE GIVE IN DATA STATEMENTS, FOLLOWED BY"
16 24 PRINT "ALL VALUES FOR A SECOND VARIABLE, AND SO ON."
17 26 PRINT "THE WAY TO ARRANGE INPUT IS TO PUT ALL VALUES OF VARIABLE 1 AT LINES"
18 28 PRINT "100-199, ALL FOR VARIABLE 2 AT LINES 200-299, ECT."
19 30 PRINT
20 31 PRINT " CURFIT ACCEPTS UP TO 200 OBSERVATIONS ON TWO VARIABLES. THE DATA FOR"
21 32 PRINT " THE DEPENDENT VARIABLE Y IS SUPPLIED FIRST, FOLLOWED BY THE"
22 33 PRINT " DATA FOR THE INDEPENDENT VARIABLE X."
23 34 PRINT
24 35 STOP
25 700DATA1E38,1E38
26 701DATA0,0
27 702 REM
28 703PRINT
29 704READP
30 705DIMX200,Y200,U200,V200,A6,B6,C6,S6,F6
31 706IFP=1E38THEN911
32 707FORK=1TO6
33 708LETFK=1
34 709NEXTK
35 710RESET
36 711PRINT
37 712PRINT"PLEASE SPECIFY THE NUMBER OF VALUES N GIVEN AS DATA"
38 713PRINT"FOR THE TWO INPUT VARIABLES, AND THE OUTPUT CODE D."
39 714PRINT"D=1 IF OUTPUT IS TO BE IN ORDER OF INCREASING VALUES"
40 715PRINT"OF THE INDEPENDENT VARIABLE ELSE D=0. N,D = ";
41 716INPUTN,D
42 717PRINT
43 718FORI=1TON
44 719READYI
45 720NEXTI
46 721FORI=1TON
47 722READXI
48 723NEXTI
49 724READX,Y
50 725 IF X < 1E38 THEN 916
51 726 IF Y < 1E38 THEN 916
52 727PRINT
53 728PRINT
54 730 PRINT " L E A S T S Q U A R E S C U R V E F I T"
55 731PRINT
56 732 PRINT"CURVE TYPE"," INDEX OF"," A"," B"
57 733PRINT" ","DETERMINATION"
58 734PRINT
59 735FORI=1TO6
60 736FORI1=1TO6
61 737LETSI1=0
62 738NEXTI1
63 739GOSUB844
64 740IFI-5*I-6=0THEN755
65 741IFI-2*I-3=0THEN748
66 742FORJ=1TON
67 743LETVJ=YJ
68 744GOSUB822
69 745NEXTJ
70 746IFI=1THEN765
71 747GOTO776
72 748FORJ=1TON
73 749IFYJ<=0THEN762
74 750LETVJ=LOGYJ
75 751GOSUB822
76 752NEXTJ
77 753IFI=3THEN770
78 754GOTO765
79 755FORJ=1TON
80 756IFYJ=0THEN762
81 757LETVJ=1/YJ
82 758GOSUB822
83 759NEXTJ
84 760IFI=6THEN776
85 761GOTO765
86 762PRINT"CAN'T FIT"
87 763LETFI=0
88 764GOTO783
89 765FORJ=1TON
90 766LETUJ=XJ
91 767GOSUB825
92 768NEXTJ
93 769GOTO781
94 770FORJ=1TON
95 771IFXJ<=0THEN762
96 772LETUJ=LOGUJ
97 773GOSUB825
98 774NEXTJ
99 775GOTO781
100 776FORJ=1TON
101 777IFXJ=0THEN762
102 778LETUJ=1/XJ
103 779GOSUB825
104 780NEXTJ
105 781GOSUB886
106 782PRINTCI,AI,BI
107 783NEXTI
108 784IFD<>1THEN786
109 785GOSUB829
110 786PRINT
111 787PRINT
112 788PRINT
113 789PRINT"DETAILS FOR";
114 790INPUTI
115 791LETK=I
116 792LETD1=D
117 793PRINT
118 794IFFI=1THEN798
119 795GOSUB844
120 796PRINT" COULD NOT BE FIT."
121 797GOTO786
122 798GOSUB862
123 799IFI-1*I-5*I-6<>0THEN810
124 800FORJ=1TON
125 801LETY=AI+BI*XJ
126 802IFI=1THEN806
127 803LETY=1/Y
128 804IFI=5THEN806
129 805LETY=XJ*Y
130 806GOSUB901
131 807NEXTJ
132 808LETD=D1
133 809GOTO786
134 810FORJ=1TON
135 811IFI=2THEN817
136 812IFI=3THEN815
137 813LETY=A4+B4/XJ
138 814GOTO818
139 815LETY=A3*XJ^B3
140 816GOTO818
141 817LETY=A2*EXPB2*XJ
142 818GOSUB901
143 819NEXTJ
144 820LETD=D1
145 821GOTO786
146 822LETS5=S5+VJ^2
147 823LETS3=S3+VJ
148 824RETURN
149 825LETS1=S1+UJ
150 826LETS2=S2+UJ^2
151 827LETS4=S4+UJ*VJ
152 828RETURN
153 829FORI=1TON-1
154 830LETM=I
155 831FORJ=I+1TON
156 832IFXM<=XJTHEN834
157 833LETM=J
158 834NEXTJ
159 835IFM=ITHEN842
160 836LETP=XM
161 837LETQ=YM
162 838LETXM=XI
163 839LETYM=YI
164 840LETXI=P
165 841LETYI=Q
166 842NEXTI
167 843RETURN
168 844LETK=I
169 845IFK=1THEN860
170 846IFK=2THEN858
171 847IFK=3THEN856
172 848IFK=4THEN854
173 849IFK=5THEN852
174 850PRINT"6. Y=X/A+B*X ";
175 851RETURN
176 852PRINT"5. Y=1/A+B*X ";
177 853RETURN
178 854PRINT"4. Y=A+B/X",
179 855RETURN
180 856PRINT"3. Y=A*X^B",
181 857RETURN
182 858PRINT"2. Y=A*EXPB*X";
183 859RETURN
184 860PRINT"1. Y=A+B*X",
185 861RETURN
186 862PRINT" ";
187 863GOSUB845
188 864PRINT" IS A";
189 865IFK=1THEN870
190 866IFK=2THEN872
191 867IFK=3THEN874
192 868PRINT" HYPERBOLIC";
193 869GOTO875
194 870PRINT" LINEAR";
195 871GOTO875
196 872PRINT"N EXPONENTIAL";
197 873GOTO875
198 874PRINT" POWER";
199 875PRINT" FUNCTION. THE RESULTS"
200 876IFK=1THEN878
201 877PRINT" OF A LEAST-SQUARES FIT OF ITS LINEAR TRANSFORM"
202 878IFD<>1THEN880
203 879PRINT" SORTED IN ORDER OF ASCENDING VALUES OF X"
204 880PRINT" ARE AS FOLLOWS:"
205 881PRINT
206 882 PRINT " X-ACTUAL Y-ACTUAL Y-CALC PCT DIFFER"
207 883PRINT
208 884RETURN
209 885PRINT
210 886LETB=N*S4-S1*S3/N*S2-S1^2
211 887LETA=S3-B*S1/N
212 888LETS1=S5-S3^2/N
213 889LETS2=B^2*S2-S1^2/N
214 890LETCI=S2/S1
215 891IFI-1*I-4*I-5=0THEN898
216 892IFI-2*I-3=0THEN896
217 893LETA6=B
218 894LETB6=A
219 895RETURN
220 896LETAI=EXPA
221 897GOTO899
222 898LETAI=A
223 899LETBI=B
224 900RETURN
225 901PRINTXJ,YJ,Y,
226 902LETD=YJ-Y
227 903LETD=.1*SGND*INT1000*ABSD/Y
228 904IFD<0THEN909
229 905IFD>0THEN908
230 906PRINT" 0"
231 907RETURN
232 908PRINT" ";
233 909PRINTD
234 910RETURN
235 911 PRINT
236 912 PRINT " DATA STATEMENTS ARE REQUIRED, SEE INSTRUCTIONS."
237 914 PRINT
238 915 STOP
239 916 PRINT
240 917 PRINT"CHECK INPUT"
241 9999 END