PREGR.TXT File Polynomial Curve Fit By Dennis York Copyright (c) 1992 Hewlett-Packard Company. Overview -------- This HP-48 program is called 'PREGR' (short for polynomial regression). PREGR takes [x, y] data from the two-dimensional reserved variable {Sigma}DAT and returns a polynomial least square fit to that data. The order of the polynomial is determined by a positive, non-zero, integer in level 1 of the stack. Given an integer of 4, the program would return a polynomial of the form: 'Y = a*X^4 + b*X^3 + c*X^2 + d*X + e' where a, b, c, d, and e would be real coefficients of the independent variable X. The program first plots a scatter diagram of the data. It then determines the coefficients and defines the equation. It then plots the equation against the scatter diagram. After plotting the equation the routine terminates in the SOLVER with the equation in level 1 of the stack and in the reserved variable EQ. You may use the solver to compute Y given X or X given Y. No error checking of input data is performed. The x data need not be evenly spaced as is required in some polynomial regression programs. This program is based on an HP-28S program submitted to HP by Dr. Robert C. Wyckoff. Example ------- Fit the data below to a polynomial of degree three. x: 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 y: 2.72 3.49 4.48 5.75 7.39 9.49 12.1 15.6 20.00 Keystrokes: Comments: [STAT] Bring up statistics menu. |CL{Sigma}| Clear {Sigma}DAT. [1 2.72 Key in first [x,y] pair as vector. |{SIGMA}+| Put first pair in {Sigma}DAT. 1.25 [ENTER] 3.49 |{SIGMA}+| Input next data point. . . . Key in rest of the data. . 3 [ENTER] 20 |{SIGMA}+| Key in last data point. [VAR] Select variable menu containing |PREGR|. 3 Define the degree as 3. |PREGR| See a scatter diagram. See a plot of the fit. See the equation in the SOLVE application. --------------------------------------------------------------------------- V 1.0 04/26/92 02:35 PM