Application Center - Maplesoft

App Preview:

Polynomial Regression through Least Square Method

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

 

INSITTUTO DE ESTUDIOS SUPERIORES DE TAMAPULIPAS
RED DE UNIVERSIDADES AN?HUAC
 

Image 

M?XICO MMVI 

 

Polynomial Regression through Least Square Method 

 

Prof. David Macias Ferrer
david.macias@iest.edu.mx
Madero City, Mexico
http://www.geocities.com/dmacias_iest/MyPage.html 

 

 

Goals 

 

  • To approximate a Points Dispersion through Least Square Method using a Quadratic Regression Polynomials and the Maple Regression Commands.
 

  • To show the powerful Maple 10 graphics tools to visualize the convergence of this Polynomials.
 

Least Square Method using a Regression Polynomials 

 

Let [Typesetting:-mrow(Typesetting:-mi(] ∀k∈ℕ be a dispersion point in Typesetting:-mrow(Typesetting:-mi(. A general regression polynomials is given by: 

Typesetting:-mrow(Typesetting:-mi( 

where Typesetting:-mrow(Typesetting:-mi(etc. According the Least Square principle, the coefficient Typesetting:-mrow(Typesetting:-mi( can be determined by: 

[c[k]] = ([Sum(f[j](x[k])*y[k], k = 1 .. n)])[nx1]/([Sum(f[i](x[k])*f[j](x[k]), k = 1 .. n)])[nxn] 

 

Application 

 

Problem: Supose that we have the follow points dispersion: 

Typesetting:-mrow(Typesetting:-mi( 

Typesetting:-mrow(Typesetting:-mi( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

Typesetting:-mrow(Typesetting:-mn( 

 

To use the Maple Tools to find a Quadratic Regression Polynomials to aproximate the dispersion using Least Square Method. 

According the Least Square Method, the Regresion Polynomials of second degree is given by: 

 

Typesetting:-mrow(Typesetting:-mi( 

where Typesetting:-mrow(Typesetting:-mi(. Then, the coefficient Typesetting:-mrow(Typesetting:-mi( are given by: 

 

Typesetting:-mrow(Typesetting:-mi( 

 

restart 

with(Spread); -1 

The following spreadsheet showing the points dispersion: 

 

Dis 

 

In this spreadsheet, the group of yellow cells represent the points dispersion; H2 represent Typesetting:-mrow(Typesetting:-mi( ; H3 and I2 represent Typesetting:-mrow(Typesetting:-mi( ;  J2, I3 and H4 represent Typesetting:-mrow(Typesetting:-mi(  ; J3 and I4 represent Typesetting:-mrow(Typesetting:-mi( ; J4 represent Typesetting:-mrow(Typesetting:-mi( , (see green cells). On the other hand, K2 represent Typesetting:-mrow(Typesetting:-mi( ; K3 represent Typesetting:-mrow(Typesetting:-mi( ; finally, the cell K4 represent Typesetting:-mrow(Typesetting:-mi(  ,(see cyan cells).  

 

Using the Spread Tools, we have: 

 

SetSelection(Dis, 2, 8, 4, 10); -1 

A := GetValuesMatrix(Dis); 1 

Matrix(%id = 147853024) (3.1)
 

SetSelection(Dis, 2, 11, 4, 11); -1 

B := GetValuesMatrix(Dis) 

Matrix(%id = 151783856) (3.2)
 

with(LinearAlgebra); -1 

 

The coefficients of Quadratic Polynomials are given by: 

 

C := Typesetting:-delayDotProduct(MatrixInverse(A), B) 

Matrix(%id = 152927588) (3.3)
 

C[1, 1] 

1.00507551897576874 (3.4)
 

C[2, 1] 

.864675848193854790 (3.5)
 

C[3, 1] 

.843164151806149675 (3.6)
 

Finally, the Quadratic Polynomials is: 

 

p := 1.00507551897576874+.864675848193854790*x+.843164151806149675*x^2 

1.00507551897576874+.864675848193854790*x+.843164151806149675*x^2 (3.7)
 

 

The above mentioned, shows the habitual procedure in a typical class of numeric methods in engineering, this is, what the student has to make in a written exam. But, in an applied problem of science, the Maple Tools can simplify the solution process. 

 

Now, we have the Statistics Package to find the quadratic polynomials 

 

with(Statistics); -1 

 

X := Vector([0, .25, .5, .75, 1], datatype = float); -1 

Y := Vector([1, 1.284, 1.6487, 2.117, 2.7183], datatype = float); -1 

PolynomialFit(2, X, Y) 

Vector[column](%id = 152580504) (3.8)
 

QuadPoly := PolynomialFit(2, X, Y, x) 

1.00513714285714317+.864182857142856143*x+.843657142857143993*x^2 (3.9)
 

Let us see the residual sum of squares and the standard errors: 

 

PolynomialFit(2, X, Y, x, output = ([residualsumofsquares, standarderrors])) 

[0.274132571428563387e-3, Vector[row](%id = 147904472)] (3.10)
 

 

Let us see the graphics of Points Dispersion, p and QuadPoly: 

 

plot({p, [[0, 1], [.25, 1.284], [.5, 1.6487], [.75, 2.117], [1, 2.7183]]}, x = 0 .. 1, title =
plot({p, [[0, 1], [.25, 1.284], [.5, 1.6487], [.75, 2.117], [1, 2.7183]]}, x = 0 .. 1, title =
 

Plot
 

plot({QuadPoly, [[0, 1], [.25, 1.284], [.5, 1.6487], [.75, 2.117], [1, 2.7183]]}, x = 0 .. 1, title =
plot({QuadPoly, [[0, 1], [.25, 1.284], [.5, 1.6487], [.75, 2.117], [1, 2.7183]]}, x = 0 .. 1, title =
 

Plot
 

 

 

Bibliography 

Burden R, Faires D., "Numerical Analysis", Fifth Edition, USA, PWS Publishing Company, 1993 

 


Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.
 

Image