As a simple example, consider the three points (-1,7), (1,1), and (2,4). If we seek to find the values of a, b, and c so that the quadratic polynomial g(x) = ax2+bx+c goes through the three points then we get the following equations,
a-b+c = 7
a+b+c = 1
4a+2b+c = 4which are obtained by substituting an x value into g and setting it equal to the y value. For example, the first equation comes from substituting x=-1, y=7 into the equation g(x) = y. Solving this set of linear equations gives the values a=2, b=-3, and c=2. You can easily check that the quadratic g(x)=2x2-3x+2 goes through the three points.
The polynomial of degree n which passes through n+1 data points is called an interpolating polynomial. An example of how to use Maple to compute interpolating polynomials is in the Getting started worksheet for this project.
|x, square feet||1350||1600||1980||2930|
Fit this data with a cubic polynomial, using x for the independent variable. Then use your result to estimate the energy consumption y for a house of area 2000 square feet.
Suppose that you know that the relationship between two variables is linear. If you collected experimental data and plotted the results, you would expect them to all lie on a straight line. However, because of experimental errors or other problems there is almost never a single line containg all of the data points. In this case, one has to somehow choose the straight line that ``best'' fits the data. In this part of the project, we describe a commonly-used technique, called least squares regression, for getting the ``best'' fit.
Suppose that you have n data points (xi, yi), for ,where . You want to find values of a and b so that a linear equation of the form y=ax+b ``best'' fits the data. The method of least squares starts by defining the following error function
which adds up the sum of the squares of the vertical distances between the data points and the straight line. The values of a and b are determined by minimizing the value of E(a,b) over all values of the parameters a and b, using the standard procedure from calculus. That is, we take the partial derivatives of E with respect to a and b and set them equal to zero. This results in the following two equations.
Please make sure you understand where these equations come from, as one of the exercises asks you to explain.
The next step is to rearrange these two equations so that all terms involving a and b are on the left-hand side and all other terms are on the right-hand side. This produces the following two linear equations.
Note that a and b are the only unknowns in these equations. The other terms are all numbers which can be calculated from the data. An example of using Maple to do a least squares regression is in the Getting started worksheet for this project.
|x, years||y, hertz||x, years||y, hertz|
This document was generated using the LaTeX2HTML translator Version 97.1 (release) (July 13th, 1997)
Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split +0 project_template.tex.
The translation was initiated by William W. Farr on 9/7/1999
William W. Farr