© 2001 by CRC Press LLC
Output[4] = —Graphics—
Input[5]: = Show[%,Graphics[Table[Text[“X”,{XYS[[i]]}],{i,1,5}]]]
Output[5] = —Graphics—
In Input[1], << loads the specified package `SplineFit`. Input[2] illustrates how
the coordinates of points can be entered as pairs and ; can be used to suppress the
display of the output. “Cubic” spline fit is requested in Input[3] and in Input[5] the
ParametricPlot command is applied so that the coordinates of the points on the cubic
spline curves are generated using a third parameter. Input[5] also demonstrates how
a matrix should be called in a looping situation.
Notice that two plots for Output[4] and Output[5] are not presented here, for
the reason that Figure 9 already shows all of the needed details. However, it should
be mentioned that use of “X” as the character in Text for marking the five XYS
points in Input[5] will enable it to be centered at the coordinates specified instead
of being upwardly offset as is the case of using the character “*” in Figure 9.
2.6 PROBLEMS
E
XACT CURVE-FIT
1. Modify the program ExactFit so that the given points (1,3), (3,8), and
(4,23) can be exact-fitted by the equation y = c
1
x + c
2
x
2
+ c
3
x
4
.
2. Modify the program ExactFit so that the given points (0,0.2), (2,0.5),
(5,–0.4), and (7,–0.2) can be exact-fitted by the equation y = c
1
sinx +
c
2
sin2x + c
3
sin3x + c
4
sin4x.
LEASTSQ1
1. Given five points (1,1), (2,3), (3,2), (4,5), and (5,4), calculate the coeffi-
cients c
1
and c
2
in the linear equation y = c
1
+ c
2
x which fits the five points
by the least-squares method.
2. For a given set of data (1,–2), (2,0), (3,1), and (4,3), two equations have
been suggested to fit these points. They are Y = X–2 and Y = (-X
2
+
7X–10)/2. Based on the least-squares criterion, which equation should be
chosen to provide a better fit? Explain why?
3. During a tensile-strength test of a metallic material the following data
(X
i
,Y
i
) for i = 1,2,…,7 where X and Y represent strain (extension per unit
length) and stress (force per unit area), respectively, have been collected:
X .265 .395 .695 .955 1.35 2.05 2.45 (x10
–3
)
Y 1.03 1.41 1.71 2.09 2.42 2.76 3.01 (x10
3
)