|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 1280 (0x500) Types: TextFile Names: »SIMPSON.PAS«
└─⟦08ea08c61⟧ Bits:30003924 PolyPascal programmer └─ ⟦this⟧ »SIMPSON.PAS« └─⟦09235ab48⟧ Bits:30003065 Demoprogrammer K-Z til Pascal bog └─ ⟦this⟧ »SIMPSON.PAS« └─⟦092727b26⟧ Bits:30005927 Demoprogrammer til Pascal bog (Jet-80) └─ ⟦this⟧ »SIMPSON.PAS«
PROGRAM simpson; VAR a, b, eps : REAL; FUNCTION f(x : REAL) : REAL; BEGIN f := 1 / SQRT(2 * PI) * EXP(- x * x / 2); END; FUNCTION integral(a, b, epsilon : REAL) : REAL; VAR x, nysum, glsum, h, sum1, sum2 : REAL; i, n : INTEGER; BEGIN n := 1; nysum := (f(a) + f(b)) * (b - a) / 2; REPEAT glsum := nysum; n := n * 2; h := (b - a) / n; x := a; sum1 := 0; FOR i := 1 TO n DIV 2 - 1 DO BEGIN x := x + 2 * h; sum1 := sum1 + f(x); END; x := a - h; sum2 := 0; FOR i := 1 TO n DIV 2 DO BEGIN X := x + 2 * h; sum2 := sum2 + f(x); END; nysum := (f(a) + f(b) + 2 * sum1 + 4 * sum2) * h / 3; UNTIL ABS(glsum-nysum) / ABS(nysum) <= epsilon; integral := nysum; END; BEGIN WRITE(CLRHOM); WRITE('Tast venstre endepunkt a: '); READLN(a); WRITE('Tast højre endpunkt b: '); READLN(b); WRITE('Tast den ønskede relative nøjagtighed: '); READLN(eps); WRITELN('Arealet er: ', integral(a, b, eps) : 10 : 6); END. «eof»