E208: Least Squares Polynomial Fit

Author(s): E. Keil Library: KERNLIB
Submitter: B. Schorr Submitted: 01.12.1969
Language: Fortran Revised: 27.11.1984

tex2html_wrap150

Subroutine LSQ fits a polynomial of degree m-1 to n equally-weighted data points ( tex2html_wrap_inline112 ). The computed coefficients tex2html_wrap_inline114 of the fitted polynomial have values which minimize

displaymath116

For the case m=2 (straight line fit), subroutine LLSQ is faster and easier to use than LSQ.

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

Structure:

SUBROUTINE subprograms
User Entry Names: LSQ, LLSQ
Files Referenced: Printer
External References: RVSUM, RSEQN, DSEQN, KERMTR, ABEND

Usage:

    CALL LSQ(N,X,Y,M,A)
    CALL LLSQ(N,X,Y,A1,A2,IFAIL)
N
(INTEGER) Number n of data points.
X
(REAL) One-dimensional array. X(i) must be equal to the data coordinate tex2html_wrap_inline124 ,
tex2html_wrap_inline126 .
Y
(REAL) One-dimensional array. Y(i) must be equal to the observed value tex2html_wrap_inline128 ,
tex2html_wrap_inline130 .
M
(INTEGER) On entry, M must be equal to the number m of coefficients of the polynomial to be fitted. On exit, the value of M may differ from this (see Error Handling).
A
(REAL) One-dimensional array. On exit from LSQ, A(j) is equal to the coefficient of tex2html_wrap_inline134 in the fitted polynomial, tex2html_wrap_inline136 .
A1,A2
(REAL) On exit from LLSQ, A1 and A2 are equal to the coefficients of the fitted straight line tex2html_wrap_inline138 .
IFAIL
(INTEGER) On exit from LLSQ, IFAIL is equal to -2 if tex2html_wrap_inline140 , to -1 if the matrix of normal equations is numerically singular, and to zero otherwise.

Method:

Normal equations.

Error handling:

Error E208.1: tex2html_wrap_inline142 or tex2html_wrap_inline144 or tex2html_wrap_inline146 (subroutine LSQ). M is replaced by zero.
Error E208.2: The normal equations matrix is numerically singular (subroutine LSQ).
For each error, a message is printed unless subroutine KERSET (N001) has been called.

Notes:

On computers other than Cray and CDC double-precision arithmetic is used internally.
tex2html_wrap_inline148


Michel Goossens Wed Jun 5 02:13:33 METDST 1996