identificationdivision. program-id. simpson. * aus Wirth, systematisches Programmieren p. 95 author. "JD". date-written. 11.9.2005. date-compiled. datadivision. working-storagesection.
78 eps pic 9(4)V9(4) compvalue 0.0001.
77 i pic 9(4) comp.
77 n pic 9(4) comp.
77 s pic 9(4)V9(4) comp.
77 ss pic 9(4)V9(4) comp.
77 diff pic 9(4)V9(4) comp.
77 s1 pic 9(4)V9(4) comp.
77 s2 pic 9(4)V9(4) comp.
77 s4 pic 9(4)V9(4) comp.
77 h pic 9(4)V9(4) comp.
77 temp1 pic 9(4)V9(4) comp. linkagesection.
77 a pic 9(4)V9(4).
77 b pic 9(4)V9(4).
77 r pic 9(4)V9(4). proceduredivisionusing a b r. * computes Integral f(x) in [a,b] move 2 to n compute h = (b - a) * 0.5 compute s1 = h * (function f(a) + function f(b)) move 0 to s2 compute temp1 = a + h compute s4 = 4 * h * function f(temp1) add s1 s2 s4 giving s subtract ss from s giving diff performuntilfunction abs(diff) < eps * function abs(s) move s to ss multiply 2 by n divide 2 into h multiply 0.5 by s1 compute s2 = 0.5 * s2 + 0.25 * s4 move 0 to s4 move 1 to i performuntil i > n compute temp1 = a + i * h compute s4 = s4 +function f(temp1) add 2 to i end-perform compute s4 = 4 * h * s4 compute s = s1 + s2 + s4 end-perform compute r = s / 3. * now s = s / 3 end-program simpson.
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.