PROGRAM d10r8(input,output); (* driver for routine F1DIM *) (*$I MODFILE.PAS *) CONST ndim = 3; TYPE RealArrayNP = ARRAY [1..ndim] OF real; VAR i,j,LinminNcom: integer; p,xi: RealArrayNP; LinminPcom,LinminXicom: RealArrayNP; FUNCTION fnc(x: RealArrayNP): real; (* Programs using routine FNC must define the type TYPE RealArrayNP = ARRAY [1..ndim] OF real; in the main routine, where ndim is the dimension of vector x. *) VAR f: real; i: integer; BEGIN f := 0.0; FOR i := 1 TO 3 DO f := f+sqr(x[i]-1.0); fnc := f END; (*$I F1DIM.PAS *) FUNCTION fx(x: real): real; BEGIN fx := f1dim(x) END; (*$I SCRSHO.PAS *) BEGIN p[1] := 0.0; p[2] := 0.0; p[3] := 0.0; LinminNcom := ndim; writeln; writeln('Enter vector direction along which to'); writeln('plot the function. Minimum is in the'); writeln('direction 1.0 1.0 1.0 - enter x y z:'); read(xi[1],xi[2],xi[3]); writeln; FOR j := 1 TO ndim DO BEGIN LinminPcom[j] := p[j]; LinminXicom[j] := xi[j] END; scrsho END.