E201: Least Squares Polynomial Fit

Author(s): K.S. Kölbig Library: MATHLIB
Submitter: Submitted: 01.12.1994
Language: Fortran Revised:

Subroutine subprograms RLSQPM and DLSQPM fit a polynomial

displaymath112

of degree m to n equally-weighted data points ( tex2html_wrap_inline118 ). The calculated coefficients tex2html_wrap_inline120 are such that

displaymath122

Subroutine subprograms RLSQP1 and DLSQP1 fit a straight line tex2html_wrap_inline124 to n such points.

Subroutine subprograms RLSQP2 and DLSQP2 fit a parabola tex2html_wrap_inline128 to n such points.

An estimate tex2html_wrap_inline132 of the standard deviation tex2html_wrap_inline134 is calculated.

On CDC and Cray computers, the double-precision versions DLSQPM, DLSQP1 and DLSQP2 are not available.

Structure:

SUBROUTINE subprograms
User Entry Names: RLSQPM, RLSQP1, RLSQP2, DLSQPM, DLSQP1, DLSQP2
External References: RVSET, DVSET, DVSUM, DVMPY, DSEQN

Usage:

For tex2html_wrap_inline136 (type REAL), tex2html_wrap_inline138 (type DOUBLE PRECISION),

    CALL tLSQPM(N,X,Y,M,A,SD,IFAIL)
    CALL tLSQP1(N,X,Y,A0,A1,SD,IFAIL)
    CALL tLSQP2(N,X,Y,A0,A1,A2,SD,IFAIL)
N
(INTEGER) Number n of data points.
X
(type according to t) One-dimensional array of length tex2html_wrap_inline142 . On entry, X(i) contains the abscissas tex2html_wrap_inline144 .
Y
(type according to t) One-dimensional array of length tex2html_wrap_inline146 . On entry, Y(i) contains the ordinates tex2html_wrap_inline148 .
M
(INTEGER) Degree m of the polynomial to be fitted.
A
(type according to t) One-dimensional array of dimension (0:d), where tex2html_wrap_inline152 . Contains, on exit, in A(j) the coefficients tex2html_wrap_inline154 .
A0,A1,A2
(type according to t) Contain, on exit, the coefficients tex2html_wrap_inline156 , tex2html_wrap_inline158 for tex2html_wrap_inline160 or tex2html_wrap_inline162 for tex2html_wrap_inline164 , respectively.
SD
(type according to t) Contains, on exit, the estimate s.
IFAIL
(INTEGER) Error flag.
tex2html_wrap_inline168 Normal case,
tex2html_wrap_inline170 tex2html_wrap_inline172 or tex2html_wrap_inline174 or tex2html_wrap_inline176 or tex2html_wrap_inline178 ,
tex2html_wrap_inline180 The matrix of normal equations is numerically singular.
In the case tex2html_wrap_inline182 : tex2html_wrap_inline184 , tex2html_wrap_inline186 and tex2html_wrap_inline188 on exit.

Method:

The normal equations are solved. On computers other than CDC or Cray, double-precision mode arithmetic is used internally for RLSQPM, RLSQP1 and RLSQP2.

Notes:

Meaningful results can usually be obtained only for small values of m (typically tex2html_wrap_inline192 ).

References:

  1. D.H. Menzel, Fundamental formulas of physics, v. 1, (Dover, New York 1960) 116-122.
tex2html_wrap_inline194

Michel Goossens Wed Jun 5 02:05:55 METDST 1996