H.K.D.H. Bhadeshia,
Phase Transformations Group,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge, U.K.
Added to MAP: June 1999.
To calculate a least squares fit of a second order polynomial to an (x,y) data set.
Language: | FORTRAN |
Product form: | Source code |
SUBROUTINE MAP_UTIL_POLY(X,Y,NPNT,A) DOUBLE PRECISION X(6),Y(6),A(3),COEF(3,3) INTEGER NPNT
MAP_UTIL_POLY calculates a least squares fit of a second order polynomial to an (x,y) data set. The input data consists of sets of x,y pairs. The routine calculates the coefficients of the polynomial:
which give a least squares fit to the input data. These coefficients are returned to the calling routine.
None.
None.
No information supplied.
The size of the arrays X and Y are currently set to 6 but should be set to a value not less than NPNT for use with values of NPNT>6.
IMPLICIT NONE DOUBLE PRECISION A(3),X(6),Y(6) INTEGER L1,NPNT C WRITE(*,*) 'Input number of data sets:' READ (*,*) NPNT WRITE(*,*) 'Input x,y pairs:' DO 100 L1=1,NPNT READ(*,*) X(L1),Y(L1) 100 CONTINUE CALL MAP_UTIL_POLY(X,Y,NPNT,A) WRITE(*,1) A(1),A(2),A(3) STOP 1 FORMAT(/'A(1)=',F8.3/'A(2)=',F8.3/'A(3)=',F8.3) END
Input number of data sets: 6 Input x,y pairs: 0.761 0.302 0.809 0.332 0.857 0.332 0.905 0.306 0.952 0.222 1.000 0.055
A(1)= -6.860 A(2)= 17.277 A(3)= -10.351
None.
least squares regression, least squares fit, polynomial
MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.
MAP Website administration / map@msm.cam.ac.uk