--- title: "Intro to Integration" type: "article" slug: "intro-to-integration" url: "http://localhost/article/intro-to-integration/" markdown_url: "http://localhost/article/intro-to-integration.md" published_at: "2026-11-03T10:18:24+00:00" modified_at: "2026-11-03T10:19:44+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "If you had trouble following Tom's integration article, here's a presentation of computer integration from more of an applications standpoint. After you've gotten your toes wet with this article, you might find that you can now dig out those dusty textbooks and, with Tom's help, integrate anything any old way. Though Tom refers to the…" post_tag: - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" publication_r: id: 10245 title: "SyncWare News" type: "periodical" url: "http://localhost/periodical/syncware-news/" volume: "1" issues_articles: - id: 38991 title: "SyncWare News v1" type: "issue" url: "http://localhost/issue/syncware-v1/" pages: "108-109" pubdate: "June 1983 – June 1984" archive_link: false --- # Intro to Integration If you had trouble following Tom’s integration article, here’s a presentation of computer integration from more of an applications standpoint. After you’ve gotten your toes wet with this article, you might find that you can now dig out those dusty textbooks and, with Tom’s help, integrate anything any old way. Though Tom refers to the core routine in this program as “Fred Rule,” I have to cop to the fact that I originally got it from some unsung (and unlisted) programmer involved with writing the TRS-80 Pocket Computer manual. Who knows where it came from originally – probably some fellow in the 60’s on a discrete-transistors mainframe. ### INTRO TO INTEGRATION RAM REQUIRED – 1K up. This program performs the calculus operation of integration, which is useful for finding areas under curves, computing average and root-mean-squared (RMS) values, and anytime you need to know how much of an accumulation of something occurs as a function of time or some other variable. For example, if a graph shows daily gross income, then the integral of the graph over a certain time span would represent total gross income received during that time. From this you can compute average daily income by dividing by the number of days in the time span you added up, or integrated. In electronics it is useful to find average levels of various voltage or current waveforms. INTEGRATION fits into 1K, since the function values are calculated instead of stored in memory. As a result, it will only work with functions that can be expressed as an algebraic expression. ``` 2 FAST 5 PRINT TAB 10;"[illegible]" 7 PRINT "INPUT FUNCTION F(X)","Y="; 8 INPUT B$ 9 CLS 10 PRINT "Y=";B$;TAB 0;"X(0)="; 20 INPUT X0 30 PRINT X0 40 PRINT "X(F)="; 50 INPUT XF 60 PRINT XF 70 PRINT "NO. DIVS="; 80 INPUT D 90 PRINT D 100 LET B=(XF-X0)/2/D 110 LET A=0 120 LET X=X0 130 LET Y=VAL B$ 140 LET A=Y+A 150 LET X=X+B 160 LET Y=VAL B$ 170 LET A=Y*4+A 180 LET X=X+B 190 LET Y=VAL B$ 200 LET A=Y+A 220 IF XF-X>1E-6 THEN GOTO 140 230 LET S=A*B/3 240 PRINT ,,"[illegible]=";S 250 PRINT "[illegible]=";S/(XF-X0) 260 PRINT ,,"SAME F(X)?" 265 PAUSE 40000 280 IF INKEY$="Y" THEN GOTO 9 290 IF INKEY$="N" THEN RUN 295 CLS ``` Enter RUN to start the program. You are asked to INPUT an expression of the function to be integrated, in terms of independent variable X. For example, a sine wave with a peak amplitude of 100 volts can be represented by F(X)= 100*SIN X. Entering this, the computer prints the function and prompts the limits of integration, i.e. from what starting point X0 to what ending point XF. If we want the average level or integral over a full cycle of the wave you would enter zero and 2*PI, respectively. You then enter how many divisions you want the function broken into; generally, higher numbers give better accuracy but this can be offset by inaccuracies in evaluating the function, etc. – the recommended range for typical functions is 10 – 50. Entering 10, the computer proceeds to sum the integral, printing it and the average level. In this example, the answer is very close to zero, as expected since the “negative area” of the second half of the wave exactly cancels the “positive area” of the first half. To use the same function in another problem, press “Y”. Let’s try it, and this time make XF=Pi – i.e., we’re only integrating over the first half-cycle. This time the value of the integral is 200.00068, very close to the exact value for this problem of 200. Also as expected, the average voltage over the half-cycle is 63.622, or about 63.7% of the peak value. If you ever wondered how this value was derived, now you know. The program uses Simpson’s Rule to evaluate the integral, the most accurate approximation for many functions (accurate up to third degree polynomial. If you’re curious, look up Simpson’s Rule and work out how the program performs the operation. ### RMS CALCULATOR You can modify the INTEGRATION program to calculate RMS instead of average values. The RMS value is also called the “effective” value, as it represents the DC voltage or current that would produce the same average power in a fixed resistance (linear circuit). Delete line 240, and change/add the following lines: ``` 5 PRINT TAB 15;"rms" 135 LET Y=Y*Y 165 LET Y=Y*Y 195 LET Y=Y*Y 230 LET S=SQR ((A*B/3)/(XF-X0)) 250 PRINT "rms value=";S ``` Use the Y=100*SIN X example as above, integrating first over a half-cycle (X0=0, XF=Pi) and then over a whole cycle (X0=0, XF=2*Pi). The answers are the same this time. (Why?) You can use this to find the RMS value of any function that can be algebraically expressed (and therefore can be evaluated by computer). In this program as well as the INTEGRATION program, it is alright to enter an odd number for “No. of Divs.” This is because the function is actually evaluated at twice the number of data points as specified by “No. of divs.” so the total number of points is always even (a requirement for correct results using Simpson’s Rule).