2
© 2001 by CRC Press LLC
Exact, Least-Squares, and
Cubic Spline Curve-Fits
2.1 INTRODUCTION
Engineers conduct experiments and collect data in the laboratories. To make use of
the collected data, these data often need to be fitted with some particularly selected
curves. For example, one may want to find a parabolic equation y = c
1
+ c
2
x + c
3
x
2
which passes three given points (x
i
,y
i
) for i = 1,2,3. This is a problem of
exact curve-
fit
. Or, since knowing in advance that these three points should all fall on a straight
line, but the reason that they are not is because of bad calibration of the measuring
equipment or because of presence of noises in the testing environment.
In case that we may want express this straight line by the equation y = c
1
+ c
2
x
for the stress and strain data collected for a stretching test of a metal bar in the
elastic range, then the question of how to determine the two coefficients c
1
and c
2
is a matter of deciding on which criterion to adopt. The
Least-Squares
method is
one of the criteria which is most popularly used. The two cases cited are the
consideration of adopting the two and three lowest
polynomial
terms, x
0
, x
1
, and x
2
,
and linearly combining them.
If the collected data are supposed to represent a sinusoidal function of time, the
curve to be determined may have to be assumed as x(t) = c
1
sint + c
2
sin3t + c
3
sin5t
+ c
4
sin7t by linearly combining 4 odd sine terms. This is the case of selecting four
particular functions, namely, f
i
(t) = sin(2i–1)t for i = 1,2,3,4., and to determine the
coefficients c
1–4
by application of the least-squares method.
Often some special form of curve needs to be selected to fit a given set of data,
the least-squares criterion can still be applied if mathematical transformations can
be found to convert the equation describing the curve into linear equations. This is
discussed in a section devoted to transformed least-squares curve-fit.
Another commonly applied curve-fit technique is the cubic spline method which
allows smooth cubic equations to be derived to ensure continuous slopes and cur-
vatures passing all given points. The mathematics involved in this method will be
presented.
In the following sections, we shall discuss the development of the programs
ExactFit
,
LeastSq1
,
LeastSqG
, and
CubeSpln
for the four curve-fit needs men-
tioned above.
2.2 EXACT CURVE FIT
As another example of solving a matrix equation, let us consider the problem
of finding a parabolic equation y = c
1
+ c
2
x + c
3
x
2
which passes three given points