procedure approxicon (F,VAR,GAM,R,M,N,A,B,NB,EPS,X); value M,N,NB,EPS; real procedure F; procedure VAR; integer M,N,NB; real EPS; array GAM,R,A,B,X;
Calculation of the best uniform approximation to a continuous function F(x) on the union of NB closed disjoint intervals [A[i], B[i]] by a linear combination x[1] × F1(x)+ ....... + X[N] × FN(x) satisfying the M linear constraints:
X[1] × GAM [1,1] + ............... + X[N] × GAM[1,N] = R[1] ............ ........................... ...... X[1] × GAM [M,1] + ............... + X[N] × GAM[M,N] = R[M]
The basic functions F1, ... , FN must be specified by
procedure VAR (x,y); real x; array y;
which associates Y[i] with Fi(x). EPS is usually set to 0.001. The method used is the Remes exchange algorithm, which calculates a lower bound mr and an upper bound Mr to the error norm. These are automatically output by the procedure. The process stops at the rth iteration when Mr - mr < EPS × Mr.
As a result of the generality of this procedure, the execution time may be quite long (2½ minutes for a simple example).
procedure remez (FCTF,N,PO,PI,X,EPS); value N; real procedure FCTF; integer N; real PO,PI,EPS; real array X;
Best uniform approximation or a continuous function FCTF on [PO,PI] by a polynomial X[1] × YN + .... + X[N+1]. The error norm is stored in X[N+2]. Set EPS between 0.0001 and 0.1. Uses the Remes algorithm.
procedure tchebecha (M,N,Y,B,X); array Y,B,X; integer M,N;
Best uniform approximation of a continuous function on a discrete point set by a linear combination X[1] × F1 + .... + X[N] × FN of continuous functions. Y[1:M] must contain the values of the function and B[1:M,1:N] the values of the basis functions. The error norm is stored in X[N+1]. The method (Stiefel-Remes) converges in a finite number of steps.
procedure chebfit (M,N,X,Y,A); integer M,N; real array X,Y,A;
Best uniform approximation of a continuous function Y on M points X by the polynomial A[0] + A[1] × x + ..... a[N] × xN. The method is that of Stiefel-Remes.
procedure chebdessous (A,B,N,F,EPS,H,ALPHA,P,E); value A,B,N,EPS,H; real A,B,EPS,H; integer N; real procedure F; real array ALPHA,P,E;
Best one-sided uniform approximation to a continuous function F on [A,B] by a linear combination ALPHA[1] × G1 + ...... + ALPHA[N] ×GN such that the error F-ΣI ALPHA[I] × GI is always positive. The values GI(x) must be specified externally by
procedure cal (X,G); value X; real X; array G;
which associates GI with G[I]. The maximum error is output in ALPHA[N+1]. The values of the errors at the critical points P[1:N+1] are contained in E[1:N+1]. H is a parameter of the discretisation (say 0.001) and EPS is put between 0.1 and 0.001.
procedure tchfbing (M,N,K,G,F,C,A,E,EPS,BOOL); value M,N,K,EPS; Boolean BOOL; integer M,N,K; real EPS; array G,F,C,A,E;
Discrete Chebyshev approximation with inequality constraints. The vector F[K+1,K+N] is approximated at N points by a linear combination H = A[1 ] × G1 + ... + A[M] × GM where the Gi have K + N components and from the rows of G[1:M,1:K+N]. The first K components of the approximating function H satisfy the K constraints H[j] ≤ C[j], for C[1:K]. The error norm is output in A [M+ 1] and the errors F - G in E [K+ 1:K+N]. Also the constraints are checked by outputting C - G in E [1:K]. Thus E is declared [1:K+N]. EPS = 0.01 or 0.001. If EPS is too small we have BOOL=false.
procedure mcpolysp (K,M,X,Y,SIGMA,S,ALPHA,BETA,ERROR); integer K,M; array X,Y,SIGMA,S,ALPHA,BETA,ERROR; real procedure P(K,S,ALPHA,BETA,X); integer K; real X; array S,ALPHA,BETA;
Least squares approximation of function values Y[i] at M points X [i] by orthogonal polynomials S[0] P0(x) + ...... + S[K] PK(x). The standard deviations of the random variables Y[i] are input to SIGMA[i]. The standard deviations of the coefficients S[i] are in ERROR[i]. The orthogonal polynomials are generated by standard recurrence relations with coefficients ALPHA[1:K] and BETA[0:K-1] . These are generated internally. The values of the approximating polynomial are calculated by P.
procedure methdintepoly (K,N,X,Y,D); value K,N,X,Y; integer K,N; array X,Y,D; real procedure polinte(K,N,X,D,T); value K,N,X,D,T; integer K,N; array X,D; real T;
Interpolating spline of order K which takes on the values Y[i] at points X[i], i =1, ..., N. The derivatives of order 0 to K-1 at these points are output in D[1:N,0:K-1]. Method works best for K ≤ 5, N ≤ 60. Values at any point x = T are produced by polinte.
procedure coefsplinetrois (N,X,Y,M); value N,X,Y; integer N; array X,Y,M;
Cubic spline with values Y[i] at X[i], i = 0, ..., N. The second derivatives are output in M[0:N].
real procedure sp(N,X,Y,M,T); value N,X,M; integer N; array X,Y,M; real T;
Values of the cubic spline obtained above at the point x=T.
procedure splinehermite (N,Y,YP,X,L,M,CC); value N,Y,YP,X; integer N; array Y,YP,X,L,M,CC; real procedure hermspl(N,X,L,M,CC,T); value N,X,L,M,CC; integer N; array X,L,M,CC; real T;
The first procedure calculates the coefficients L[1:N-2], M[1:N-1], CC[1:3] of the Hermite spline taking values Y[i] and derivatives YP[i] at (monotonically ordered) points x[i], i = 1, ..., N. (N ≥ 4). The second procedure calculates the value at x=T of this spline.
real procedure splderivee(N,X,Y,T); value N,X,Y,T; integer N; array X,Y; real T;
Best approximation (in the sense of Sard) to the derivative at x=T of a function taking the values Y[i] at points X[i], i = 0,..., N. Method uses a cubic spline.