home *** CD-ROM | disk | FTP | other *** search
- PROGRAM d5r5(input,output);
- (* driver for routine CHEBEV *)
- LABEL 10,99;
- CONST
- nval=40;
- pio2=1.5707963;
- TYPE
- glcarray=ARRAY [1..nval] OF real;
- VAR
- a,b,x : real;
- i,mval : integer;
- c : glcarray;
-
- FUNCTION func(x: real): real;
- BEGIN
- func := sqr(x)*(sqr(x)-2.0)*sin(x)
- END;
-
- (*$I MODFILE.PAS *)
- (*$I CHEBFT.PAS *)
-
- (*$I CHEBEV.PAS *)
-
- BEGIN
- a := -pio2;
- b := pio2;
- chebft(a,b,c,nval);
- (* test chebyshev evaluation routine *)
- 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;
- writeln;
- writeln('x':9,'actual':14,'chebyshev fit':16);
- FOR i := -8 to 8 DO BEGIN
- x := i*pio2/10.0;
- writeln(x:12:6,func(x):12:6,chebev(a,b,c,mval,x):12:6)
- END;
- GOTO 10;
- 99:
- END.
-