PROGRAM d5r9(input,output); (* driver for routine PCSHFT *) LABEL 10,99; CONST nval=40; pio2=1.5707963; TYPE glcarray= ARRAY [1..nval] OF real; VAR a,b,poly,x : real; i,j,mval : integer; c,d : glcarray; FUNCTION func(x: real): real; BEGIN func := sqr(x)*(sqr(x)-2.0)*sin(x) END; (*$I MODFILE.PAS *) (*$I CHEBFT.PAS *) (*$I CHEBPC.PAS *) (*$I PCSHFT.PAS *) BEGIN a := -pio2; b := pio2; chebft(a,b,c,nval); 10: writeln; writeln('How many terms in Chebyshev evaluation?'); write('Enter n between 6 and ',nval:2, '. (n := 0 to end). '); readln(mval); IF ((mval <= 0) OR (mval > nval)) THEN GOTO 99; chebpc(c,d,mval); pcshft(a,b,d,mval); (* test shifted polynomial *) writeln; writeln('x':9,'actual':14,'polynomial':14); FOR i := -8 to 8 DO BEGIN x := i*pio2/10.0; poly := d[mval]; FOR j := mval-1 DOWNTO 1 DO BEGIN poly := poly*x+d[j] END; writeln(x:12:6,func(x):12:6,poly:12:6) END; GOTO 10; 99: END.