home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1994 August
/
1994-08b.d64
/
mtool
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
225 lines
10 rem copyright 1994 - compute publications intl ltd - all rights reserved
20 print"[147]":poke 53280,6:poke 53281,6
30 print"[158]":ms$="[205]athematics [212]oolbox":gosub 5000
40 print"[159]":ms$="by [194]ruce [205]. [194]owden":gosub5000:print""
50 ms$="[195]opyright 1994":gosub5000:ms$="[195][207][205][208][213][212][197] [208]ublications [201]ntl [204]td":gosub5000
60 ms$="[193]ll [210]ights [210]eserved":gosub 5000:gosub6000
70 rem this program is self-modifying. do not renumber
100 goto150
110 deffnf(x)=x*x
120 return
130 deffng(x)=x
140 return
150 print"[147][213]se the function keys to make your selection:"
160 print"f1 *** [201]ntegral [211]olution"
170 print"f3 *** [210]oots by [194]isection"
180 print"f5 *** [198]actorization of [201]ntegers"
185 print"f7 *** [209]uit the program "
190 geta$:ifa$=""ora$<"[133]"ora$>"[136]"then190
200 print"[147]":x=asc(a$)-132:on x goto 210,1410,1750,3000
210 print" [201][206][212][197][199][210][193][212][201][207][206][160][194][217][160][211][201][205][208][211][207][206]'[211][160][193][208][208][210][207][216][201][205][193][212][201][207][206]"
220 print"[212]his part of the [205]athematics [212]oolbox"
230 print"[208]rogram uses [211]impson's [193]pproximation to"
240 print"solve for various integration problems.":gosub 6000
250 print"[147][213]se the function keys to make your selection:"
260 print"f1 *** [193]rea under a rectangular curve"
270 print"f3 *** [193]rea under a polar curve"
280 print"f5 *** [193]rea between two rectangular curves"
290 print"f7 *** [193]rea between two polar curves"
300 print"f2 *** [196][201][211][208][204][193][217] [205][207][210][197][160][195][200][207][201][195][197][211]"
310 geta$:ifa$=""then310
320 x=asc(a$)-132:ifx<1orx>5then310
330 print"[147]":onxgoto 490,560,630,690,340
340 print"[193]dditional [211]elections:"
350 print"f1 *** [204]ength of a rectangular curve"
360 print"f3 *** [204]ength of a polar curve"
370 print"f5 *** [211]urface of revol. about y-axis"
380 print"f7 *** [211]urface of revol. about x-axis"
390 print"f2 *** [196][201][211][208][204][193][217] [205][207][210][197][160][195][200][207][201][195][197][211]"
400 geta$:ifa$=""ora$<"[133]"ora$>"[137]"then400
410 x=asc(a$)-132:print"[147]":onxgoto 730,780,820,880,420
420 print"[193]dditional [211]elections:"
430 print"f1 *** [211]olid of revolution about y-axis"
440 print"f3 *** [211]olid of revolution about x-axis"
450 print"f5 *** [193]verage for a curve"
460 print"f7 *** [210][197][214][201][197][215] [195][200][207][201][195][197][211]"
465 print"f2 *** [210][197][212][213][210][206][160][212][207][160][205][193][201][206][160][205][197][206][213]"
470 geta$:ifa$=""ora$<"[133]"ora$>"[137]"then470
480 print"[147]":x=asc(a$)-132:onxgoto 920,980,1010,250,150
490 print"[147] [193][210][197][193][160][213][206][196][197][210] [193][160][210][197][195][212][193][206][199][213][204][193][210][160][195][213][210][214][197] [146]"
500 zz=510:goto2480
510 pr=1:gosub110
520 gosub1230
530 print"[212]he integral of your function, from":printa;"to";b;
540 print"[157], by [211]impson's [193]pproximation":print"with";c;"partitions, is"
545 printi
550 gosub 6000:goto150
560 print"[147] [193][210][197][193][160][213][206][196][197][210][160][193][160][208][207][204][193][210][160][195][213][210][214][197] [146]"
570 zz=580:goto2480
580 pr=2:gosub110:gosub130
590 gosub1230
600 print"[212]he integral of your function, from":printa;"to";b;
610 print"[157], by [211]impson's [193]pproximation":print"with";c;"partitions, is"
615 printi
620 gosub 6000:goto150
630 print"[147] [193][210][197][193][160][194][197][212][215][197][197][206][160][212][215][207][160][210][197][195][212][193][206][199][213][204][193][210][160][195][213][210][214][197][211] [146]"
640 zz=650:goto2520
650 pr=3:gosub110:gosub130
660 gosub1230
670 print"[212]he area, from";a;"to";b:print"with";c;"partitions, is"
675 printi
680 goto620
690 print"[147] [193][210][197][193][160][194][197][212][215][197][197][206][160][212][215][207][160][208][207][204][193][210][160][195][213][210][214][197][211] [146]"
700 zz=710:goto2520
710 pr=4:gosub110:gosub130
720 goto660
730 print"[147] [204][197][206][199][212][200][160][207][198][160][193] [210][197][195][212][193][206][199][213][204][193][210][160][195][213][210][214][197] [146]"
740 zz=750:goto2480
750 pr=5:gosub110:gosub130
760 gosub1230
770 print"[212]he length, from";a;"to";b:print"with";c;"partitions, is"
775 print i:goto620
780 print"[147] [204][197][206][199][212][200][160][207][198][160][193] [208][207][204][193][210][160][195][213][210][214][197] [146]"
790 zz=800:goto2480
800 pr=6:gosub110:gosub130
810 goto760
820 print"[147] [211][213][210][198][193][195][197][160][207][198][160][210][197][214][207][204][213][212][201][207][206][160][193][194][207][213][212][160][217]-[193][216][201][211] [146]"
830 zz=840:goto2480
840 pr=7:gosub110:gosub130
850 gosub1230
860 print"[212]he surface of revolution,":print"from";a;"to";b;
870 print"with";c;"partitions, is":printi;"square units":gosub 6000:goto150
880 print"[147] [211][213][210][198][193][195][197][160][207][198][160][210][197][214][207][204][213][212][201][207][206][160][193][194][207][213][212][160][216]-[193][216][201][211] [146]"
890 zz=900:goto2480
900 pr=8:gosub110:gosub130
910 goto850
920 print"[147] [211][207][204][201][196][160][207][198][160][210][197][214][207][204][213][212][201][207][206][160][193][194][207][213][212][160][217]-[193][216][201][211] [146]"
930 zz=940:goto2480
940 pr=9:gosub110:gosub130
950 gosub1230
960 print"[212]he solid of revolution,":print"from";a;"to";b;
970 print"with";c;"partitions, is":printi;"cubic units":gosub 6000:goto150
980 print"[147] [211][207][204][201][196][160][207][198][160][210][197][214][207][204][213][212][201][207][206][160][193][194][207][213][212][160][216]-[193][216][201][211] [146]"
990 zz=1000:goto2480
1000 pr=10:gosub110:gosub130:goto950
1010 print"[147] [193][214][197][210][193][199][197][160][214][193][204][213][197][160][207][198][160][193][160][198][213][206][195][212][201][207][206] [146]"
1020 zz=1030:goto2480
1030 pr=11:gosub110:gosub130
1040 gosub1230
1050 print"[147][212]he average value in the interval from":printa;"to";b;
1060 print"with";c;"partitions, is"
1065 print i:gosub 6000:goto150
1070 on pr goto 1080,1090,1100,1110,1120,1170,1180,1190,1200,1210,1220
1080 ev=fnf(x):return
1090 ev=.5*fnf(x)^2:return
1100 ev=abs(fnf(x)-fng(x)):return
1110 ev=abs(.5*(fnf(x)^2-fng(x)^2)):return
1120 gosub1130:ev=sqr(1+ev^2):return
1130 m1=x:ifx=0then1160
1140 m2=10^(log(abs(x))/log(10)-4)
1150 x=m1+m2:m3=fnf(x):x=m1-m2:ev=(m3-fnf(x))/2/m2:x=m1:return
1160 m2=1e-18:goto1150
1170 gosub1130:ev=sqr(fnf(x)^2+ev^2):return
1180 gosub1120:ev=2*(NULL)*x*ev:return
1190 gosub1120:ev=2*(NULL)*fnf(x)*ev:return
1200 ev=2*(NULL)*fnf(x)*x:return
1210 ev=(NULL)*fnf(x)^2:return
1220 ev=fnf(x)/(b-a):return
1230 input"[147][215]hat is the [204]ower [194]ound";a
1240 input"[215]hat is the [213]pper [194]ound";b
1250 input"[215]hat number of partitions";c:c=2*int(c/2+.5):print"";
1255 ms$="[195]omputing...":gosub5000
1260 p=(b-a)/3/c:x=a:gosub1070:y=ev:l=y:x=b:gosub1070:y=ev:l=l+y:o=(b-a)/c
1270 r=c-1:t=0
1280 x=o*r+a:gosub1070:y=ev:r=r-2:t=t+y:ifr=-1then1330
1290 goto1280
1300 r=c-2:t=0
1310 x=o*r+a:gosub1070:y=ev:r=r-2:t=t+y:ifr=0then1340
1320 goto1310
1330 l=l+4*t:goto1300
1340 i=p*(l+2*t):q$="":print"[147]":return
1350 :
1360 rem end of simpson
1370 :
1380 :
1390 rem start of roots
1400 :
1410 print" [210][207][207][212][211][160][194][217][160][194][201][211][197][195][212][201][207][206]"
1420 print"[212]his part of the [205]athematics [212]oolbox"
1430 print"[208]rogram uses the bisection method to"
1440 print"solve for the unknown in any single-"
1450 print"variable function such that f(x)=0."
1460 gosub 6000
1470 zz=1480:print"[147]":goto2480
1480 print"[147]"
1490 input"[147][215]hat is the lower bound of the interval to be searched"