$If 0 ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Program : Simpsons Rule (Evaluate an integral)³ Version : 0.0 º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º Written by Kurt J. Wolf ³ [X] Released to public º º Copyright 1994 by Kurt J. Wolf ³ [ ] Do not release to public º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º Compiler : PowerBASIC ³ Compiler Version : 3.0c º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Home : 39 Brentwood Rd School : PSU - MA Box 267 Camp Hill, PA 17011 Mont Alto, PA 17237 (717) 763-8913 (717) 749-6430 InterNet : kjw124@psuvm.psu.edu ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ< Notes >Ä ---This is another method for evaluating a definit integral. This method will not return the same values found using the trapazoid rule, they are two different beasts. If you would like to use this code, feel free, I don't mind, just drop me a line and tell me that you are using it. (More of an ego boost than anything!) ---Thank you once again, Lloyd. $Endif function f#(x#) public f# = x# ^ 2 + 1.0 end function function integrand#(a#, b#, n#) public h# = (b# - a#) / n# h2# = h# / 2 for i% = 1 to n# - 1 x# = a# + i% * h# sum1# = sum1# + f#(x#) sum2# = sum2# + f#(x# + h2#) Next i% integrand# = h# * (f#(a#) + 2.0 * sum1# + f#(b#) + 4.0 * sum2#) / 6.0 end function print str$(integrand#(0, 1, 10)) print str$(integrand#(0, 1, 20)) print str$(integrand#(0, 1, 100))