-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path08_Function_analyser.bc2
130 lines (129 loc) · 4.11 KB
/
08_Function_analyser.bc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
1000 A=100:GOTO20:REM FUNCTION PROPERTIES
1010 GOSUB100:PRINT:PRINT"FUNCTION PROPERTIES"
1100 PRINT:PRINT"1) INTEGRATION"
1110 PRINT:PRINT"2) DIFFERENTIATION"
1120 PRINT:PRINT"3) ZERO POINT"
1130 PRINT:PRINT"4) ARC LENGTH"
1140 PRINT:PRINT"5) INSTRUCTIONS"
1150 PRINT:PRINT"6) END"
1160 PRINT:PRINT
1170 PRINT"Your choice";:GOSUB210:K=VAL(IN$)
1180 IF(K<1) OR(K>6) THEN1010
1190 ONK GOSUB2000,3000,4000,5000,6000,1999
1200 PRINT:PRINT"PRESS";:GOSUB210:GOTO1010
1500 REM Y=F(X) ******
1510 Y=SIN(X)+X*X
1520 REM *************
1530 RETURN
1999 END
2000 REM INTEGRATION
2005 REM (SIMPSON)
2010 GOSUB100:PRINT:PRINT"INTEGRATION"
2020 PRINT:PRINT"Lower limit";:INPUTX1:PRINT"Upper limit";
2030 INPUTX2:IFX1>X2 THEN2020
2040 PRINT:PRINT"Number of decimals ";
2050 INPUTE:E=10^-(INT(E+.5))
2100 PRINT:PRINT" STEP INTEGRAL":PRINT
2110 H=X2-X1:X=X1:GOSUB1500:T1=Y
2120 X=X2:GOSUB1500:T1=(T1+Y)*H/2
2130 X=X1+H/2:GOSUB1500:M1=Y*H
2140 H=H/2:A=2:T2=(T1+M1)/2:M2=0
2150 FORI=.5 TO2:X=I*H+X1:GOSUB1500
2160 M2=M2+Y*H:NEXTI:S1=T2
2200 H=H/2:A=A*2:T3=(T2+M2)/2:M3=0
2210 FORJ=.5 TOA:X=J*H+X1:GOSUB1500
2220 M3=M3+Y*H:NEXTJ
2230 S2=(T1+2*M1)/3:GOSUB2500:T1=T2:T2=T3:M1=M2:M2=M3
2240 S0=S1:S1=S2:IFABS(S1-S0)>3*E THEN2200
2300 REM SLOT INT.
2310 H=H/2:S2=(T1+2*M1)/3:GOSUB2500
2320 PRINT:PRINT"The integral from ":PRINTX1;" to ";X2
2330 PRINT"is ";:GOSUB2530
2340 RETURN
2500 REM PRINT TABLE
2510 SR=INT(2*H*1E5+.5)/1E5
2520 CN=5:CT=9:GOSUB310:PRINTSR$;" ";
2530 SR=INT(S2/E+.5)*E
2540 CN=INT(LOG(1/E)/LOG(10)+.5)
2550 CT=INT(7+CN/2):GOSUB310:PRINTSR$
2560 RETURN
3000 REM DIFFERENTIATION
3010 GOSUB100:PRINT:PRINT"DERIVATIVE"
3020 PRINT:PRINT"For which X ";:INPUTX1
3030 PRINT:PRINT"Number of decimals ";
3040 INPUTE:E=10^-(INT(E+.5))
3100 PRINT:PRINT" STEP DIFFER. ":PRINT
3110 S=.1:I=0
3200 X=X1-S:GOSUB1500:Y1=Y:X=X1+S:GOSUB1500:Y2=Y:IV=I
3210 I=(Y2-Y1)/(S*2)
3220 H=S:S2=I:GOSUB2500:S=S/2
3230 IFABS(IV-I)>E THEN3200
3300 PRINT:PRINT"The derivative in"
3310 PRINTX1;" is ";:GOSUB2530
3320 RETURN
4000 REM ZERO POINT
4010 REM REGULA FALSI
4020 GOSUB100:PRINT:PRINT"ZERO POINT":PRINT
4030 PRINT"Lower limit";:INPUTX1:PRINT"Upper limit";
4040 INPUTX2
4050 X=X1:GOSUB1500:Y1=Y:X=X2:GOSUB1500:Y2=Y
4060 IF(Y1>0) AND(Y2>0) THENPRINT"Error":GOTO4030
4070 IF(Y1<0) AND(Y2<0) THENPRINT"Error":GOTO4030
4080 PRINT:PRINT"Number of decimals ";
4090 INPUTE:E=10^-(INT(E+.5))
4100 PRINT:PRINT" STEP ZERO POINT":PRINT
4110 X=X1:GOSUB1500:Z=SGN(Y)
4120 X4=(X1+X2)/2
4200 X=X1:GOSUB1500:Y1=Y:X=X2:GOSUB1500:Y2=Y
4210 X3=(X1*Y2-X2*Y1)/(Y2-Y1)
4220 H=(X3-X4)/2:S2=X3:GOSUB2500
4230 X=X3:GOSUB1500
4240 IFY*Z<0 THENX2=X3:GOTO4260
4250 X1=X3
4260 IFABS(X3-X4)>E THENX4=X3:GOTO4200
4300 H=(X3-X4)/2:S2=X3:GOSUB2500
4310 PRINT:PRINT"The zero point is":GOSUB2530:RETURN
5000 REM ARC LENGTH
5010 REM TRAPEZIUM
5020 GOSUB100:PRINT:PRINT"ARC LENGTH":PRINT
5030 PRINT"Lower limit";:INPUTX1:PRINT"Upper limit";
5040 INPUTX2:IFX1>X2 THEN5030
5050 PRINT:PRINT"Number of decimals ";
5060 INPUTE:E=10^-(INT(E+.5))
5100 PRINT:PRINT" STEP ARC":PRINT
5110 H=X2-X1:L=0
5200 L1=L:L=0:FORI=X1 TOX2-H STEPH:X=I
5210 GOSUB1500:YA=Y:X=I+H:GOSUB1500:YB=Y
5220 L=L+SQR(H^2+(YB-YA)^2):NEXTI
5230 H=H/2:S2=L:GOSUB2500
5240 IFABS(L-L1)>E THEN5200
5300 PRINT:PRINT"The arc length"
5310 PRINT"from ";X1;" to ";X2
5320 PRINT"is";:GOSUB2530:RETURN
6000 REM EXPLANATION
6010 GOSUB100:PRINT:PRINT"FUNCTION PROPERTIES"
6020 PRINT:PRINT:PRINT"INSTRUCTIONS"
6030 PRINT"This program calculates":PRINT"some properties"
6040 PRINT"of a given function.":PRINT
6050 PRINT"In this case, the function":PRINT"is stored";
6060 PRINT"in line 1510."
6070 PRINT:PRINT"Line 1510 Y=SIN(X)+X*X"
6080 PRINT:PRINT"You can obviously change"
6090 PRINT"the function to suit your needs."
6100 RETURN
30000 REM
30010 REM FUNCTION ANALYSER
30020 REM
30030 REM H.VAN DEELEN
30040 REM
30050 REM RUDOLPHLN.30
30060 REM
30070 REM DE GLIND GLD
30080 REM
30090 REM THE NETHERLANDS
30100 REM
30110 REM WRITTEN ON A VIC 20
30120 REM
30130 REM TRANSLATED FOR
30135 REM RADIO NETHERLANDS
30140 REM BY JONATHAN MARKS