+'ô ************************************* +'ô * A function for approximate * +$'ô * integration by the trapezoidal * +.'ô * rule. (C) Danny Langton 11/88 * +8'ô *...................................* +B'ô * Incorporate in your own programs * +L'ô * by using a call like : * +V'ô * area=FNintegral(lowX, highX, * +`'ô * no_of_intervals, fx$) * +j'ô * where fx$ is a function of x as a * +t'ô * string. e.g., * +~'ô * area=FNintegral(0,0.75,10,"x^3") * +ˆ'ô * will give an approx. integral for * +’'ô * x cubed over the range of x from * +œ'ô * 0 to 0.75 given ten inter * an be given in * + * order. n% should be greater than * +º'ô * one to get a result other than 0. * +Ä'ô ************************************* Î': +Ø'ݤintegral(a,b,n%,fx$) êx,h,area,sum,i% #â'ça>b a=a+b:b=a-b:a=a-b ‹ça=b:=0 ì'n%=”n%:çn%<2:=0 ö'x=a:h=(b-a)/n%:area= fx$ #(ãi%=1¸n%-1:x=x+h:sum=sum+ fx$:í % (x=x+h:area=(area+2*sum+ fx$)*h*.5 (=area ÿÿ