
PROGRAM LIBRARY JINRLIBOPEM2  orthonormal polynomial expansion method in two dimensions and its realization in fortran packageAuthor: Nina B.Bogdanova Institute of Nuclear Research and Nuclear Energy, Sofia, Bulgaria 

Language: Fortran 77, Windows A package of Fortran 77 programs is presented. This package has developed since 1981 for the calibration problems of measurement devices in High Energy Physics in collaboration with LIT JINR, Dubna. Last version of the package is developed in part under the contract of Bulgarian National Council for Sientific Research  Phi 1001.
1.Description of the Method Orthonormal Polynomial Expansion Method (OPEM2) is the method of orthogonalization of polynomials based on HouseholderForsythe 3term relation [1,2] (onedimensional case) and the Weisfeld recurrence [3] (manydimensional case). The recurrence family of polynomials {P_{L}} is given by:
where P_{k} is a mother term. K and I have to be determined. {P_{L}} are defined in a finite discrete subset D of , D={q_{1},q_{2},...,q_{M}}. Every point q_{j}=q_{j}(x_{1}^{j1},x_{2}^{j2},...,x_{n}^{jn}) presents a ncoordinate vector (in this case n=2). The weights, associated with them, w_{j}=1/S^{2}_{j}, depend on the standard deviation in every point. The points, the weights and the experimental function values {q_{j},w_{j},f_{j}^{exp}}_{j=1}^{M} are given. The recurrence coefficients {_{L}} and {_{L1}} and normalizing factor {c_{L}} are evaluated by scalar products of the given values. The description here follows the descriptions [3,4,7]. In OPEM2 the approximated function is given by the expansion of the orthonormal polynomials using special orthonormal coefficients a_{k}. Optimal value of polynomial degree  L_{r} is evaluated using two criteria.
Then orthonormal coefficients {a_{k}} in (1.2) are easily computed by given values:
A pyramid of twodimensional polynomials is given  the hierarchy order of polynomials in two variables: In the cell on the top the number of polynomial is given, and the degrees j_{1} and j_{2} of the x_{1} and x_{2} variables also  on the bottom. One example for evaluating K and I in (1.1) gives for the polynomial P_{13} (k=2, j_{1}=2, j_{2}=2):
(P_{8} is a mother term: K=8, I=4). New theoretical investigations are presented in twodimensional case in [7] for the case of differentiation and integration  the fourth member in the equation (1.1) is added. More detailed description of the mathematical method with manydimensional polynomials including differentiation and integration will be published later in suitable journal according the description in JINR library with some implementations.
2.Description of the package OPEM2 (fortran 77) It consists of main program CALIB and five subroutines: the principle TSTWO, ORTTWO, PRETWO and 2 auxiliary DEGREE, NUMBER. The main program CALIB gives:
The principal subroutines contain a named common /LINKS/ where the recurrence factors and auxiliary variables are recorded. The present size of /LINKS/ allows for overall degrees as high as 16 and for L_{max}=(16+1)(16+2)/2=153. The array dimensions in /LINKS/ may be changed. The subroutine TSTWO(X,Y,W,M,F,A,NDEG) is the subroutine, which calls subprograms. First, it calls PRETWO for preparing the recurrence factors with overall degree NDEG. Afterwards it calculates the orthonormal coefficients A, calling the subroutine ORTTWO. After second call of ORTTWO it calculates the approximating values and deviations in the points, selects optimal degree L_{r}, selects min ()^{2}, calculates the errors of series coefficients after third call of ORTTWO and then prints the results.
The subroutine ORTTWO(NUMBMX,X,Y,POLY) returns the specific values of all polynomials in an orthonormal series from 1 to NUMBMX at given values of x and y in POLYarray.
The subroutine PRETWO(M,MAXD,X,Y,W,POLY) prepares the recurrence factors of twodimensional polynomials, orthonormal over a discrete point set in a single call, which must precede any working call of ORTTWO.
PRETWO makes successive recursive calls to ORTTWO with NUMBMX = L1, then L is incremented, etc, until L_{max} is reached. The subroutine DEGREE(N,J,JX,JY) calculates at given ordinary number of polynomials N the overall degree of the leading term J, the degree in xvariable JX, and that in yvariable JY. The integer function NUMBER(JX,JY) at given x degree JX and y degree JY returns the ordinary number of polynomials in a series according to Weisfeld [3] with particular stress on the leading term.
3.Applications Some applications for receiving calibration coefficients between ideal and measured grid in the optical devices in HEP are given in [5,6,7]. The last application of the package is for H1 experiment in DESY, Hamburg  to look for the coordinates of the maximum of the surface formed by gaussians. The analytic surface over the 400 point's grid is our approximation. It is done in collaboration with Dubna (LIT). 4.References
Sources of OPEM2 are submitted. 