DataMuseum.dk

Presents historical artifacts from the history of:

Jet Computer Jet80

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

See our Wiki for more about Jet Computer Jet80

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦56bd45612⟧ TextFile

    Length: 1152 (0x480)
    Types: TextFile
    Names: »MAXPUNKT.PAS«

Derivation

└─⟦092727b26⟧ Bits:30005927 Demoprogrammer til Pascal bog (Jet-80)
    └─ ⟦this⟧ »MAXPUNKT.PAS« 

TextFile

PROGRAM maxpunkt;

  VAR
    a, b, byt, x, fx, fmax, xmax, delta : REAL;
    i, antal : INTEGER;
  
  FUNCTION f(x : REAL) : REAL;
  
    BEGIN
      f := ((x - 3) * x - 9) * x + 2;
    END;
  
  BEGIN
    WRITE(CLRHOM);
    WRITE('Tast a i intervallet (a,b): '); READLN(a);
    WRITE('Tast b i intervallet (a,b): '); READLN(b);
    WRITE('Hvor mange delintervaller skal (a,b) deles op i: '); 
    READLN(antal);
    IF a > b
      THEN
        BEGIN
          byt := a;
          a := b;
          b := byt;
        END;
    delta := (b - a) / antal;
    fmax := f(a);
    xmax := a;
    x := a;
    FOR i := 1 TO antal DO
      BEGIN
        x := x + delta;
        fx := f(x);
        IF fx > fmax
          THEN
            BEGIN
              fmax := fx;
              xmax := x;
            END;
      END;
    WRITELN('Maximumsværdien for funktionen i (', a : 6 : 2 , ',', 
             b : 6 : 2, ')');
    WRITELN('baseret på ', antal + 1, ' støttepunkter: ', fmax : 10 : 4);
    WRITELN('Maximumspunktet er: ', xmax : 6 : 2);
  END.
    «eof»