DataMuseum.dk

Presents historical artifacts from the history of:

RegneCentralen RC700 "Piccolo"

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RegneCentralen RC700 "Piccolo"

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦b6bf34c6d⟧ TextFile

    Length: 1280 (0x500)
    Types: TextFile
    Names: »SIMPSON.PAS«

Derivation

└─⟦09235ab48⟧ Bits:30003065 Demoprogrammer K-Z til Pascal bog
    └─ ⟦this⟧ »SIMPSON.PAS« 

TextFile

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»