unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,unit1, Forms, Dialogs;
procedure CHEBFT(A, B:real; var C:array of real; N:integer);
Function CHEBEV(A, B:real; C:array of real; M:integer; X:real):real;
implementation
procedure CHEBFT(A, B:real; var C:array of real; N:integer);
var
K,J:integer; SUM,Y,BMA,BPA,FAC:real;
F:array[0..50] of real;
const
NMAX = 50; PI = 3.14159265358979;
begin
BMA:=0.5 * (B - A);
BPA:=0.5 * (B + A);
For K:=1 To N do
begin
Y:=Cos(PI * (K - 0.5) / N);
F[K]:=FUNC(Y * BMA + BPA);
end;
FAC:=2/ N;
For J:=1 To N do
begin
Sum:=0 ;
For K:=1 To N do
begin
Sum:=Sum + F[K] * Cos((PI * (J - 1)) * ((K - 0.5) / N));
end;
C[J]:=FAC * Sum;
end;
end;
Function CHEBEV(A, B:real; C:array of real; M:integer; X:real):real;
var
D,DD,Y,Y2,SV:real; J:integer;
begin
If (X - A) * (X - B) > 0 Then ShowMessage('X not in range.');
D:=0;
DD:=0;
Y:=(2* X - A - B) / (B - A);
Y2:=2* Y;
For J:=M DownTo 2 do
begin
SV:=D;
D:=Y2 * D - DD + C[J];
DD:=SV;
end;
CHEBEV:=Y * D - DD + 0.5 * C[1];
end;
end.